Skip to content

Commit cec7c43

Browse files
committed
Add tests for passing validations
1 parent 426d021 commit cec7c43

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tests/testthat/test-validate_linelist.R

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
test_that("tests for validate_linelist", {
2-
3-
# errors
1+
test_that("validate_linelist() detects invalid objects", {
42
msg <- "Must inherit from class 'linelist', but has class 'NULL'."
53
expect_error(validate_linelist(NULL), msg)
64

@@ -17,8 +15,22 @@ test_that("tests for validate_linelist", {
1715
validate_linelist(x),
1816
"- gender: Must inherit from class 'character'/'factor'"
1917
)
18+
})
19+
20+
test_that("validate_linelist() allows valid objects", {
21+
22+
x <- make_linelist(cars, id = "speed")
23+
24+
# Print a message
25+
expect_message(
26+
validate_linelist(x),
27+
"valid"
28+
)
29+
30+
# And returns invisibly...
31+
v <- suppressMessages(expect_invisible(validate_linelist(x)))
32+
33+
# ...an identical object
34+
expect_identical(x, v)
2035

21-
# Functionalities
22-
x <- make_linelist(cars)
23-
expect_identical(x, validate_linelist(x))
2436
})

0 commit comments

Comments
 (0)