Expectation predicate for testing that a given vector contains all values present in another vector

expect_contains(current, target, ..., info = NA_character_)

Arguments

current

[R vector] A vector to be tested

target

[R vector] A vector to be compared against

...

Ignored

info

[character(1L)] Optional user-defined message; must be a single string value

Value

A tinytest object. A tinytest object is a logical with attributes holding information about the test that was run

See also

testthat equivalent: testthat::expect_contains()

Other in-condition expectation predicates: expect_in(), expect_mapequal(), expect_setequal()

Examples

expect_contains(letters, target = rev(letters)) # Pass
#> ----- PASSED      : <-->
#>  call| expect_contains(letters, target = rev(letters)) 
expect_contains(letters, target = "b") # Pass
#> ----- PASSED      : <-->
#>  call| expect_contains(letters, target = "b") 
expect_contains("b", target = letters) # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_contains("b", target = letters)
#>  diff| Expected 'current' to contain all values of 'target'