Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jan 16, 2024
1 parent 57f4ab0 commit 6edeefa
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 0 deletions.
27 changes: 27 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-align.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]},
column{1}={halign=c,},
cell{1}{1}={}{halign=c,},
column{2}={halign=c,},
cell{1}{2}={}{halign=c,},
column{3}={halign=l,},
cell{1}{3}={}{halign=l,},
column{4}={halign=l,},
cell{1}{4}={}{halign=l,},
column{5}={halign=r,},
cell{1}{5}={}{halign=r,},
} %% tabularray inner close
\toprule
mpg & cyl & disp & hp & drat \\ \midrule %% TinyTableHeader
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\bottomrule
\end{tblr}
\end{table}
25 changes: 25 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-cell_color.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]},
cell{2}{1}={}{,fg=orange,},
cell{3}{1}={}{,fg=orange,},
cell{2}{2}={}{,fg=orange,},
cell{3}{2}={}{,fg=orange,},
cell{2}{3}={}{,fg=orange,},
cell{3}{3}={}{,fg=orange,},
cell{2}{4}={}{,fg=orange,},
cell{3}{4}={}{,fg=orange,},
} %% tabularray inner close
\toprule
mpg & cyl & disp & hp & drat \\ \midrule %% TinyTableHeader
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\bottomrule
\end{tblr}
\end{table}
21 changes: 21 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-col_color.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]},
column{1}={,fg=orange,},
column{2}={,fg=orange,},
column{3}={,fg=orange,},
column{4}={,fg=orange,},
} %% tabularray inner close
\toprule
mpg & cyl & disp & hp & drat \\ \midrule %% TinyTableHeader
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\bottomrule
\end{tblr}
\end{table}
18 changes: 18 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]},
row{even}={bg=black!5!white},
} %% tabularray inner close
\toprule
mpg & cyl & disp & hp & drat \\ \midrule %% TinyTableHeader
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\bottomrule
\end{tblr}
\end{table}
16 changes: 16 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-nohead.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]},
} %% tabularray inner close
\toprule
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\bottomrule
\end{tblr}
\end{table}
21 changes: 21 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-row_color.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]},
row{2}={,fg=orange,},
row{3}={,fg=orange,},
row{4}={,fg=orange,},
row{5}={,fg=orange,},
} %% tabularray inner close
\toprule
mpg & cyl & disp & hp & drat \\ \midrule %% TinyTableHeader
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\bottomrule
\end{tblr}
\end{table}
17 changes: 17 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-theme_grid.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
hlines,vlines,
colspec={Q[]Q[]Q[]Q[]Q[]},
hlines={},vlines={},
} %% tabularray inner close
mpg & cyl & disp & hp & drat \\
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\end{tblr}
\end{table}
18 changes: 18 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-theme_striped.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]},
row{even}={bg=black!5!white},
} %% tabularray inner close
\toprule
mpg & cyl & disp & hp & drat \\ \midrule %% TinyTableHeader
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\bottomrule
\end{tblr}
\end{table}
15 changes: 15 additions & 0 deletions inst/tinytest/_tinysnapshot/latex-theme_void.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

\begin{table}
\centering
\begin{tblr}[ %% tabularray outer open
] %% tabularray outer close
{ %% tabularray inner open
colspec={Q[]Q[]Q[]Q[]Q[]},
} %% tabularray inner close
mpg & cyl & disp & hp & drat \\
21 & 6 & 160 & 110 & 3.9 \\
21 & 6 & 160 & 110 & 3.9 \\
22.8 & 4 & 108 & 93 & 3.85 \\
21.4 & 6 & 258 & 110 & 3.08 \\
\end{tblr}
\end{table}
45 changes: 45 additions & 0 deletions inst/tinytest/test-latex.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
source("helpers.R")
using("tinysnapshot")

x <- mtcars[1:4, 1:5]

expect_snapshot_print(
tt(x, output = "latex", theme = "striped"),
label = "latex-default")

k <- x
colnames(k) <- NULL
expect_snapshot_print(
tt(k, output = "latex"),
label = "latex-nohead")

# Align
expect_snapshot_print(
tt(x, output = "latex", align = "ccllr"),
label = "latex-align")

# Themes
expect_snapshot_print(
tt(x, output = "latex", theme = "striped"),
label = "latex-theme_striped")

expect_snapshot_print(
tt(x, output = "latex", theme = "grid"),
label = "latex-theme_grid")

expect_snapshot_print(
tt(x, output = "latex", theme = "void"),
label = "latex-theme_void")

# Styles
expect_snapshot_print(
tt(x, output = "latex") |> style_tt(i = 1:4, color = "orange"),
label = "latex-row_color")

expect_snapshot_print(
tt(x, output = "latex") |> style_tt(j = 1:4, color = "orange"),
label = "latex-col_color")

expect_snapshot_print(
tt(x, output = "latex") |> style_tt(i = 1:2, j = 1:4, color = "orange"),
label = "latex-cell_color")

0 comments on commit 6edeefa

Please sign in to comment.