-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error on named NA, ignore named NULL
- Loading branch information
1 parent
528380a
commit 514f3cd
Showing
5 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
test_that("named NULL is dropped", { | ||
|
||
tcs <- list( | ||
list(list(), list()), | ||
list(list(a = 1), list(a = 1)), | ||
list(list(NULL), list(NULL)), | ||
list(list(a = NULL), list()), | ||
list(list(NULL, a = NULL, 1), list(NULL, 1)), | ||
list(list(a = NULL, b = 1, 5), list(b = 1, 5)) | ||
) | ||
|
||
for (tc in tcs) { | ||
expect_identical( | ||
drop_named_nulls(tc[[1]]), | ||
tc[[2]], | ||
info = tc | ||
) | ||
} | ||
}) | ||
|
||
test_that("named NA is error", { | ||
|
||
goodtcs <- list( | ||
list(), | ||
list(NA), | ||
list(NA, NA_integer_, a = 1) | ||
) | ||
|
||
badtcs <- list( | ||
list(b = NULL, a = NA), | ||
list(a = NA_integer_), | ||
list(NA, c = NA_real_) | ||
) | ||
|
||
for (tc in goodtcs) { | ||
expect_silent(check_named_nas(tc)) | ||
} | ||
|
||
for (tc in badtcs) { | ||
expect_error(check_named_nas(tc)) | ||
} | ||
}) |