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))
[any] Object to check.
[integer(1)
]
Exact expected length of x
.
[integer(1)
]
Minimal length of x
.
[integer(1)
]
Maximal length of x
.
[integer(1)
]
Minimum number of elements being “0”/FALSE
/off.
[integer(1)
]
Minimum number of elements being “1”/TRUE
/on.
[logical(1)
]
If set to TRUE
, x
may also be NULL
.
In this case only a type check of x
is performed, all additional checks are disabled.
[character(1)
]
Name of the checked object to print in assertions. Defaults to
the heuristic implemented in vname
.
[AssertCollection
]
Collection to store assertion messages. See AssertCollection
.
[character(1)]
Extra information to be included in the message for the testthat reporter.
See expect_that
.
[character(1)
]
Name of the checked object to print in messages. Defaults to
the heuristic implemented in vname
.
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
.
# NOT RUN {
library(bit)
x = as.bit(replace(logical(10), sample(10, 5), TRUE))
testBit(x, len = 10, min.0 = 1)
# }
Run the code above in your browser using DataLab