Skip to content

Commit ce1a1d2

Browse files
committed
test: Add tests for single row data frame.
1 parent eab4aa5 commit ce1a1d2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/testthat/test-assertions.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,17 @@ test_that("skip_chain_opts doesn't affect functionality outside chain for assert
351351
"Column 'gear' violates assertion 'within_bounds\\(3.5, 4.5\\)' 20 times.*")
352352
})
353353

354+
test_that("assert works with single row data.frames", {
355+
single_row_data <- head(mtcars, 1)
356+
357+
expect_equal(assert(single_row_data, within_bounds(10,30), disp, error_fun = error_logical), FALSE)
358+
expect_output(assert(single_row_data, within_bounds(10,30), disp, error_fun = just.show.error),
359+
"Column 'disp' violates assertion 'within_bounds\\(10, 30\\)' 1 time.*")
360+
expect_equal(assert(single_row_data, within_bounds(10,30), disp, mpg, error_fun = error_logical), FALSE)
361+
expect_output(assert(single_row_data, within_bounds(10,30), disp, mpg, error_fun = just.show.error),
362+
"Column 'disp' violates assertion 'within_bounds\\(10, 30\\)' 1 time.*")
363+
})
364+
354365
######################################
355366

356367

0 commit comments

Comments
 (0)