| 1 |
skip_on_cran() |
| 2 |
|
| 3 |
skip_if_not_installed("modeltests") |
| 4 |
library(modeltests) |
| 5 |
|
| 6 |
test_that("tidy_xyz", { |
| 7 |
check_arguments(tidy_xyz) |
| 8 |
|
| 9 |
a <- list( |
| 10 |
x = 1:5, |
| 11 |
y = 1:3, |
| 12 |
z = matrix(runif(5 * 3), nrow = 5) |
| 13 |
) |
| 14 |
|
| 15 |
b <- list( |
| 16 |
x = 1:5, |
| 17 |
y = 1:3, |
| 18 |
z = matrix(runif(4 * 2), nrow = 4) |
| 19 |
) |
| 20 |
|
| 21 |
c <- list( |
| 22 |
x = 1:5, |
| 23 |
y = 1:3, |
| 24 |
z = matrix(runif(10 * 2), nrow = 5) |
| 25 |
) |
| 26 |
|
| 27 |
d <- list(x = 1:5, y = 1:3, z = "cat") |
| 28 |
|
| 29 |
check_arguments(tidy_xyz) |
| 30 |
|
| 31 |
td <- tidy(a) |
| 32 |
|
| 33 |
check_tidy_output(td, strict = FALSE) |
| 34 |
check_dims(td, 15, 3) |
| 35 |
|
| 36 |
expect_true(is.numeric(td$x)) |
| 37 |
expect_true(is.numeric(td$y)) |
| 38 |
expect_true(is.numeric(td$z)) |
| 39 |
|
| 40 |
expect_snapshot(error = TRUE, tidy(b)) |
| 41 |
expect_snapshot(error = TRUE, tidy(c)) |
| 42 |
expect_snapshot(error = TRUE, tidy(d)) |
| 43 |
}) |