Usage
check_pick(
...,
pick = NULL,
min_pick = NULL,
max_pick = NULL,
.names = get_names(...)
)
assert_pick(
...,
pick = NULL,
min_pick = NULL,
max_pick = NULL,
.names = get_names(...)
)
test_pick(
...,
pick = NULL,
min_pick = NULL,
max_pick = NULL,
.names = get_names(...)
)
Arguments
- ...
Objects to compare.
- pick
(Optional) an integer number indicating the expected number of arguments to pick (default:
NULL
) (default:1
).- min_pick
(Optional) an integer number indicating the minimum number of arguments to pick (default:
NULL
).- max_pick
(Optional) an integer number indicating the maximum number of arguments to pick (default:
NULL
).- .names
(Optional) A
character
vector specifying the names of the objects being tested. This argument is used internally and should not be set by the user.
Value
test_*
:TRUE
if it passes the test;FALSE
otherwise.check_*
:TRUE
if it passes the test; a string with a message otherwise.assertion_*
: The same input (as invisible) if it passes the test; an error message otherwise.
Examples
x <- 1; y <- NULL
test_pick(x, y, pick = 1)
#> [1] TRUE
#> [1] TRUE # Expected
x <- 1; y <- NULL; z <- NULL
check_pick(x, y, z, pick = 2) |> cli::cli_alert_warning()
#> ! You must pick 2 of the x, y and z arguments.
#> ! You must pick 2 of the x, y and z arguments. # Expected
x <- 1; y <- NULL
check_pick(x, y, min_pick = 2) |> cli::cli_alert_warning()
#> ! You must assign the x and y arguments.
#> ! You must assign the x and y arguments. # Expected
x <- 1; y <- NULL; z <- NULL
check_pick(x, y, z, min_pick = 2) |> cli::cli_alert_warning()
#> ! You must pick 2 or more of the x, y and z arguments.
#> ! You must pick 2 or more of the x, y and z arguments. # Expected
x <- 1; y <- 1; z <- NULL
check_pick(x, y, z, max_pick = 1) |> cli::cli_alert_warning()
#> ! You must pick 1 or less of the x, y and z arguments.
#> ! You must pick 1 or less of the x, y and z arguments. # Expected