Last chance! 50% off unlimited learning
Sale ends in
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)
NULL
to check for absence of names.TRUE
, sorts names before comparing to
ignore the effect of order.TRUE
, lowercases all names to ignore the
effect of case.NULL
, computed from deparsed object.has_names
.equivalence
,
expect_equal
,
expect_equivalent
,
expect_identical
;
expect-compare
,
expect_less_than
,
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
;
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)
Run the code above in your browser using DataLab