checkBit {checkmate} | R Documentation |
Check if an argument is a bit vector
checkBit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL, min.1 = NULL, null.ok = FALSE) check_bit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL, min.1 = NULL, null.ok = FALSE) assertBit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL, min.1 = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL) assert_bit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL, min.1 = NULL, null.ok = FALSE, .var.name = vname(x), add = NULL) testBit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL, min.1 = NULL, null.ok = FALSE) test_bit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL, min.1 = NULL, null.ok = FALSE) expect_bit(x, len = NULL, min.len = NULL, max.len = NULL, min.0 = NULL, min.1 = NULL, null.ok = FALSE, info = NULL, label = vname(x))
x |
[any] |
len |
[ |
min.len |
[ |
max.len |
[ |
min.0 |
[ |
min.1 |
[ |
null.ok |
[ |
.var.name |
[ |
add |
[ |
info |
[character(1)] |
label |
[ |
Depending on the function prefix:
If the check is successful, the functions
assertBit
/assert_bit
return
x
invisibly, whereas
checkBit
/check_bit
and
testBit
/test_bit
return
TRUE
.
If the check is not successful,
assertBit
/assert_bit
throws an error message,
testBit
/test_bit
returns FALSE
,
and checkBit
returns a string with the error message.
The function expect_bit
always returns an
expectation
.
library(bit) x = as.bit(replace(logical(10), sample(10, 5), TRUE)) testBit(x, len = 10, min.0 = 1)