Skip to content

Commit ec9821c

Browse files
committed
Flatten nested test_that pattern
1 parent 0bf48fc commit ec9821c

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

cpp11test/src/test-matrix.cpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,39 @@ context("matrix-C++") {
2424
expect_true(x[1].size() == 2);
2525
expect_true(x[1].stride() == 5);
2626
}
27-
test_that("matrix dim attributes are correct for read only matrices") {
27+
28+
test_that("matrix<by_row> attributes are correct") {
29+
auto getExportedValue = cpp11::package("base")["getExportedValue"];
30+
31+
cpp11::doubles_matrix<cpp11::by_row> x(getExportedValue("datasets", "volcano"));
32+
33+
expect_true(x.size() == 5307);
34+
expect_true(x.nrow() == 87);
35+
expect_true(x.ncol() == 61);
36+
expect_true(x.nslices() == 87);
37+
expect_true(x.slice_size() == 61);
38+
expect_true(x.slice_stride() == 87);
39+
expect_true(x.slice_offset(0) == 0);
40+
expect_true(x.slice_offset(1) == 1);
41+
expect_true(x[1].size() == 61);
42+
expect_true(x[1].stride() == 87);
43+
}
44+
45+
test_that("matrix<by_column> attributes are correct") {
2846
auto getExportedValue = cpp11::package("base")["getExportedValue"];
2947

30-
test_that("matrix<by_row> attributes are correct") {
31-
cpp11::doubles_matrix<cpp11::by_row> x(getExportedValue("datasets", "volcano"));
32-
33-
expect_true(x.size() == 5307);
34-
expect_true(x.nrow() == 87);
35-
expect_true(x.ncol() == 61);
36-
expect_true(x.nslices() == 87);
37-
expect_true(x.slice_size() == 61);
38-
expect_true(x.slice_stride() == 87);
39-
expect_true(x.slice_offset(0) == 0);
40-
expect_true(x.slice_offset(1) == 1);
41-
expect_true(x[1].size() == 61);
42-
expect_true(x[1].stride() == 87);
43-
}
44-
test_that("matrix<by_column> attributes are correct") {
45-
cpp11::doubles_matrix<cpp11::by_column> x(getExportedValue("datasets", "volcano"));
46-
47-
expect_true(x.size() == 5307);
48-
expect_true(x.nrow() == 87);
49-
expect_true(x.ncol() == 61);
50-
expect_true(x.nslices() == 61);
51-
expect_true(x.slice_size() == 87);
52-
expect_true(x.slice_stride() == 1);
53-
expect_true(x.slice_offset(0) == 0);
54-
expect_true(x.slice_offset(1) == 87);
55-
expect_true(x[1].size() == 87);
56-
expect_true(x[1].stride() == 1);
57-
}
48+
cpp11::doubles_matrix<cpp11::by_column> x(getExportedValue("datasets", "volcano"));
49+
50+
expect_true(x.size() == 5307);
51+
expect_true(x.nrow() == 87);
52+
expect_true(x.ncol() == 61);
53+
expect_true(x.nslices() == 61);
54+
expect_true(x.slice_size() == 87);
55+
expect_true(x.slice_stride() == 1);
56+
expect_true(x.slice_offset(0) == 0);
57+
expect_true(x.slice_offset(1) == 87);
58+
expect_true(x[1].size() == 87);
59+
expect_true(x[1].stride() == 1);
5860
}
5961

6062
test_that("row based subsetting works") {

0 commit comments

Comments
 (0)