|
1 | | -test_that("shape computed correctly", { |
2 | | - # equivalent to expect_length |
| 1 | +test_that("length compared correctly", { |
3 | 2 | expect_success(expect_shape(1, length = 1)) |
4 | 3 | expect_snapshot_failure(expect_shape(1, length = 2)) |
5 | 4 | expect_success(expect_shape(1:10, length = 10)) |
6 | 5 | expect_success(expect_shape(letters[1:5], length = 5)) |
| 6 | +}) |
7 | 7 |
|
8 | | - # testing dim() |
| 8 | +test_that("dim compared correctly", { |
9 | 9 | expect_success(expect_shape(matrix(nrow = 5, ncol = 4), dim = c(5L, 4L))) |
10 | 10 | expect_snapshot_failure(expect_shape(matrix(nrow = 6, ncol = 3), dim = c(6L, 2L))) |
11 | 11 | expect_snapshot_failure(expect_shape(matrix(nrow = 6, ncol = 3), dim = c(7L, 3L))) |
12 | 12 | expect_success(expect_shape(data.frame(1:10, 11:20), dim = c(10, 2))) |
13 | 13 | expect_success(expect_shape(array(dim = 1:3), dim = 1:3)) |
| 14 | + expect_snapshot_failure(expect_shape(array(dim = 1:3), dim = 1:2)) |
| 15 | + expect_snapshot_failure(expect_shape(array(dim = 1:3), dim = 1:4)) |
| 16 | +}) |
14 | 17 |
|
15 | | - # testing nrow= |
| 18 | +test_that("nrow compared correctly", { |
16 | 19 | expect_success(expect_shape(matrix(nrow = 5, ncol = 4), nrow = 5L)) |
17 | 20 | expect_snapshot_failure(expect_shape(matrix(nrow = 5, ncol = 5), nrow = 6L)) |
18 | 21 | expect_success(expect_shape(data.frame(1:10, 11:20), nrow = 10L)) |
19 | 22 | expect_snapshot_failure(expect_shape(1, nrow = 1)) |
| 23 | +}) |
20 | 24 |
|
21 | | - # testing ncol= |
| 25 | +test_that("ncol compared correctly", { |
22 | 26 | expect_success(expect_shape(matrix(nrow = 5, ncol = 4), ncol = 4L)) |
23 | 27 | expect_snapshot_failure(expect_shape(matrix(nrow = 5, ncol = 5), ncol = 7L)) |
24 | 28 | expect_success(expect_shape(data.frame(1:10, 11:20), ncol = 2L)) |
|
0 commit comments