| expect_named {testthat} | R Documentation |
You can either check for the presence of names (leaving expected
blank), specific names (by suppling a vector of names), or absence of
names (with NULL).
expect_named(object, expected, ignore.order = FALSE, ignore.case = FALSE, info = NULL, label = NULL)
object |
object to test |
expected |
Character vector of expected names. Leave missing to
match any names. Use |
ignore.order |
If |
ignore.case |
If |
info |
extra information to be included in the message (useful when writing tests in loops). |
label |
object label. When |
... |
Other arguments passed onto |
Other expectations: equivalence,
expect_equal,
expect_equivalent,
expect_identical;
expect-compare, expect_gt,
expect_gte, expect_less_than,
expect_lt, expect_lte,
expect_more_than;
expect_equal_to_reference;
expect_error, expect_match,
expect_message,
expect_output,
expect_warning,
matching-expectations;
expect_false, expect_true;
expect_is; expect_null;
expect_silent;
takes_less_than
x <- c(a = 1, b = 2, c = 3)
expect_named(x)
expect_named(x, c("a", "b", "c"))
# Use options to control sensitivity
expect_named(x, c("B", "C", "A"), ignore.order = TRUE, ignore.case = TRUE)
# Can also check for the absence of names with NULL
z <- 1:4
expect_named(z, NULL)