Commit ebbc8d8 1 parent 4e53a69 commit ebbc8d8 Copy full SHA for ebbc8d8
File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 46
46
constant <- function ( name , simplify = TRUE ) {
47
47
checkmate :: assert_character(name , any.missing = F , min.chars = 1L )
48
48
checkmate :: assert_subset(name , names(constant_list ), empty.ok = F )
49
+ checkmate :: assert_logical(simplify , any.missing = F , len = 1L )
49
50
50
51
# return( constant_list[[name]] )
51
52
sapply(
Original file line number Diff line number Diff line change @@ -52,3 +52,25 @@ test_that("missing name", {
52
52
expected_error_message
53
53
)
54
54
})
55
+
56
+ test_that(" bad simplify" , {
57
+ # expected_error_message <- "Assertion on 'simplify' failed: Must be of type 'logical', not 'character'."
58
+ expect_error(
59
+ constant(" form_complete" , simplify = " aa" ),
60
+ " ^Assertion on 'simplify' failed: Must be of type 'logical', not 'character'\\ .$"
61
+ )
62
+ })
63
+ test_that(" missing simplify" , {
64
+ # expected_error_message <- "Assertion on 'simplify' failed: Must be of type 'logical', not 'NULL'. "
65
+ expect_error(
66
+ constant(" form_complete" , simplify = NULL ),
67
+ " ^Assertion on 'simplify' failed: Must be of type 'logical', not 'NULL'\\ .$"
68
+ )
69
+ })
70
+ test_that(" NA simplify" , {
71
+ # expected_error_message <- "Assertion on 'simplify' failed: Contains missing values (element 1)."
72
+ expect_error(
73
+ constant(" form_complete" , simplify = NA_character_ ),
74
+ " ^Assertion on 'simplify' failed: Contains missing values \\ (element 1\\ )\\ .$"
75
+ )
76
+ })
You can’t perform that action at this time.
0 commit comments