| Title: | Property Based Testing |
|---|---|
| Description: | Property based testing, inspired by the original 'QuickCheck'. This package builds on the property based testing framework provided by 'hedgehog' and is designed to seamlessly integrate with 'testthat'. |
| Authors: | Andrew McNeil [aut, cre] |
| Maintainer: | Andrew McNeil <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.3 |
| Built: | 2026-05-31 08:39:10 UTC |
| Source: | https://github.com/armcn/quickcheck |
Generate vectors of integer, double, character, logical, date, POSIXct, hms, or factors.
any_atomic(len = c(1L, 10L), any_na = FALSE)any_atomic(len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
A quickcheck_generator object.
any_atomic() %>% show_example() any_atomic(len = 10L, any_na = TRUE) %>% show_example()any_atomic() %>% show_example() any_atomic(len = 10L, any_na = TRUE) %>% show_example()
Generate data.frames.
any_data_frame(rows = c(1L, 10L), cols = c(1L, 10L), any_na = FALSE)any_data_frame(rows = c(1L, 10L), cols = c(1L, 10L), any_na = FALSE)
rows |
Number of rows of the generated data frame.
If |
cols |
Number of columns of the generated data frame.
If |
any_na |
Whether |
A quickcheck_generator object.
any_data_frame(rows = 3L, cols = 3L) %>% show_example()any_data_frame(rows = 3L, cols = 3L) %>% show_example()
Generate data.tables.
any_data.table(rows = c(1L, 10L), cols = c(1L, 10L), any_na = FALSE)any_data.table(rows = c(1L, 10L), cols = c(1L, 10L), any_na = FALSE)
rows |
Number of rows of the generated data frame.
If |
cols |
Number of columns of the generated data frame.
If |
any_na |
Whether |
A quickcheck_generator object.
any_data.table(rows = 3L, cols = 3L) %>% show_example()any_data.table(rows = 3L, cols = 3L) %>% show_example()
Generate lists in which each element is an atomic scalar of the same class.
any_flat_homogeneous_list(len = c(1L, 10L), any_na = FALSE)any_flat_homogeneous_list(len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
A quickcheck_generator object.
any_flat_homogeneous_list() %>% show_example() any_flat_homogeneous_list(len = 10L, any_na = TRUE) %>% show_example()any_flat_homogeneous_list() %>% show_example() any_flat_homogeneous_list(len = 10L, any_na = TRUE) %>% show_example()
Generate lists in which each element is an atomic scalar.
any_flat_list(len = c(1L, 10L), any_na = FALSE)any_flat_list(len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
A quickcheck_generator object.
any_flat_list() %>% show_example() any_flat_list(len = 10L, any_na = TRUE) %>% show_example()any_flat_list() %>% show_example() any_flat_list(len = 10L, any_na = TRUE) %>% show_example()
Generate lists containing lists or atomic vectors.
any_list(len = c(1L, 10L), any_na = FALSE)any_list(len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
A quickcheck_generator object.
any_list() %>% show_example() any_list(len = 10L, any_na = TRUE) %>% show_example()any_list() %>% show_example() any_list(len = 10L, any_na = TRUE) %>% show_example()
Generate tibbles.
any_tibble(rows = c(1L, 10L), cols = c(1L, 10L), any_na = FALSE)any_tibble(rows = c(1L, 10L), cols = c(1L, 10L), any_na = FALSE)
rows |
Number of rows of the generated data frame.
If |
cols |
Number of columns of the generated data frame.
If |
any_na |
Whether |
A quickcheck_generator object.
any_tibble(rows = 3L, cols = 3L) %>% show_example()any_tibble(rows = 3L, cols = 3L) %>% show_example()
Generate undefined values. In this case undefined values include NA,
NA_integer_, NA_real_, NA_character_, NA_complex_, NULL, -Inf,
Inf, and NaN. Values generated are always scalars.
any_undefined()any_undefined()
A quickcheck_generator object.
any_undefined() %>% show_example()any_undefined() %>% show_example()
Generate atomic vectors or lists.
any_vector(len = c(1L, 10L), any_na = FALSE)any_vector(len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
A quickcheck_generator object.
any_vector() %>% show_example() any_vector(len = 10L, any_na = TRUE) %>% show_example()any_vector() %>% show_example() any_vector(len = 10L, any_na = TRUE) %>% show_example()
Generate any R object. This doesn't actually generate any possible object,
just the most common ones, namely atomic vectors, lists, data.frames,
tibbles, data.tables, and undefined values like NA, NULL, Inf, and
NaN.
anything(any_empty = TRUE, any_undefined = TRUE)anything(any_empty = TRUE, any_undefined = TRUE)
any_empty |
Whether empty vectors or data frames should be allowed. |
any_undefined |
Whether undefined values should be allowed. |
A quickcheck_generator object.
anything() %>% show_example()anything() %>% show_example()
Convert a quickcheck generator to a hedgehog generator
as_hedgehog(generator)as_hedgehog(generator)
generator |
A |
A quickcheck_generator object.
is_even <- function(a) a %% 2L == 0L gen_powers_of_two <- integer_bounded(1L, 10L, len = 1L) %>% as_hedgehog() %>% hedgehog::gen.with(function(a) 2 ^ a) for_all( a = from_hedgehog(gen_powers_of_two), property = function(a) is_even(a) %>% testthat::expect_true() )is_even <- function(a) a %% 2L == 0L gen_powers_of_two <- integer_bounded(1L, 10L, len = 1L) %>% as_hedgehog() %>% hedgehog::gen.with(function(a) 2 ^ a) for_all( a = from_hedgehog(gen_powers_of_two), property = function(a) is_even(a) %>% testthat::expect_true() )
A set of generators for character vectors.
character_(len = c(1L, 10L), any_na = FALSE, any_empty = FALSE) character_letters(len = c(1L, 10L), any_na = FALSE, any_empty = FALSE) character_numbers(len = c(1L, 10L), any_na = FALSE, any_empty = FALSE) character_alphanumeric(len = c(1L, 10L), any_na = FALSE, any_empty = FALSE)character_(len = c(1L, 10L), any_na = FALSE, any_empty = FALSE) character_letters(len = c(1L, 10L), any_na = FALSE, any_empty = FALSE) character_numbers(len = c(1L, 10L), any_na = FALSE, any_empty = FALSE) character_alphanumeric(len = c(1L, 10L), any_na = FALSE, any_empty = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
any_empty |
Whether empty character values should be allowed. |
A quickcheck_generator object.
character_() %>% show_example() character_(len = 10L, any_na = TRUE) %>% show_example() character_(len = 10L, any_empty = TRUE) %>% show_example()character_() %>% show_example() character_(len = 10L, any_na = TRUE) %>% show_example() character_(len = 10L, any_empty = TRUE) %>% show_example()
Generate the same value every time
constant(a)constant(a)
a |
Any R object |
A quickcheck_generator object.
constant(NULL) %>% show_example()constant(NULL) %>% show_example()
Construct data frame generators in a similar way to base::data.frame.
data_frame_(..., rows = c(1L, 10L))data_frame_(..., rows = c(1L, 10L))
... |
A set of name-value pairs with the values being vector generators. |
rows |
Number of rows of the generated data frame.
If |
A quickcheck_generator object.
data_frame_(a = integer_()) %>% show_example() data_frame_(a = integer_(), b = character_(), rows = 5L) %>% show_example()data_frame_(a = integer_()) %>% show_example() data_frame_(a = integer_(), b = character_(), rows = 5L) %>% show_example()
Data frame generator with randomized columns
data_frame_of(..., rows = c(1L, 10L), cols = c(1L, 10L))data_frame_of(..., rows = c(1L, 10L), cols = c(1L, 10L))
... |
A set of unnamed generators. The generated data frames will be built with random combinations of these generators. |
rows |
Number of rows of the generated data frame.
If |
cols |
Number of columns of the generated data frame.
If |
A quickcheck_generator object.
data_frame_of(logical_(), date_()) %>% show_example() data_frame_of(any_atomic(), rows = 10L, cols = 5L) %>% show_example()data_frame_of(logical_(), date_()) %>% show_example() data_frame_of(any_atomic(), rows = 10L, cols = 5L) %>% show_example()
Construct data.table generators in a similar way to data.table::data.table.
data.table_(..., rows = c(1L, 10L))data.table_(..., rows = c(1L, 10L))
... |
A set of name-value pairs with the values being vector generators. |
rows |
Number of rows of the generated data frame.
If |
A quickcheck_generator object.
data.table_(a = integer_()) %>% show_example() data.table_(a = integer_(), b = character_(), rows = 5L) %>% show_example()data.table_(a = integer_()) %>% show_example() data.table_(a = integer_(), b = character_(), rows = 5L) %>% show_example()
data.table generator with randomized columns
data.table_of(..., rows = c(1L, 10L), cols = c(1L, 10L))data.table_of(..., rows = c(1L, 10L), cols = c(1L, 10L))
... |
A set of unnamed generators. The generated data.tables will be built with random combinations of these generators. |
rows |
Number of rows of the generated data frame.
If |
cols |
Number of columns of the generated data frame.
If |
A quickcheck_generator object.
data.table_of(logical_(), date_()) %>% show_example() data.table_of(any_atomic(), rows = 10L, cols = 5L) %>% show_example()data.table_of(logical_(), date_()) %>% show_example() data.table_of(any_atomic(), rows = 10L, cols = 5L) %>% show_example()
A set of generators for date vectors.
date_(len = c(1L, 10L), any_na = FALSE) date_bounded(left, right, len = c(1L, 10L), any_na = FALSE) date_left_bounded(left, len = c(1L, 10L), any_na = FALSE) date_right_bounded(right, len = c(1L, 10L), any_na = FALSE)date_(len = c(1L, 10L), any_na = FALSE) date_bounded(left, right, len = c(1L, 10L), any_na = FALSE) date_left_bounded(left, len = c(1L, 10L), any_na = FALSE) date_right_bounded(right, len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
left |
The minimum possible value for generated numbers, inclusive. |
right |
The maximum possible value for generated numbers, inclusive. |
A quickcheck_generator object.
date_() %>% show_example() date_bounded( left = as.Date("2020-01-01"), right = as.Date("2020-01-10") ) %>% show_example() date_(len = 10L, any_na = TRUE) %>% show_example()date_() %>% show_example() date_bounded( left = as.Date("2020-01-01"), right = as.Date("2020-01-10") ) %>% show_example() date_(len = 10L, any_na = TRUE) %>% show_example()
A set of generators for double vectors.
double_( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_bounded( left, right, len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE ) double_left_bounded( left, len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_right_bounded( right, len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_positive( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_negative( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_fractional( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_whole( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE )double_( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_bounded( left, right, len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE ) double_left_bounded( left, len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_right_bounded( right, len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_positive( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_negative( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_fractional( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE ) double_whole( len = c(1L, 10L), any_na = FALSE, any_nan = FALSE, any_inf = FALSE, big_dbl = FALSE )
len |
Length of the generated vectors. If |
any_na |
Whether |
any_nan |
Whether |
any_inf |
Whether |
big_dbl |
Should doubles near the maximum size be
included? This may cause problems because if the result
of a computation results in a double larger than the
maximum it will return |
left |
The minimum possible value for generated numbers, inclusive. |
right |
The maximum possible value for generated numbers, inclusive. |
A quickcheck_generator object.
double_() %>% show_example() double_(big_dbl = TRUE) %>% show_example() double_bounded(left = -5, right = 5) %>% show_example() double_(len = 10L, any_na = TRUE) %>% show_example() double_(len = 10L, any_nan = TRUE, any_inf = TRUE) %>% show_example()double_() %>% show_example() double_(big_dbl = TRUE) %>% show_example() double_bounded(left = -5, right = 5) %>% show_example() double_(len = 10L, any_na = TRUE) %>% show_example() double_(len = 10L, any_nan = TRUE, any_inf = TRUE) %>% show_example()
Generates equal length vectors contained in a list.
equal_length(..., len = c(1L, 10L))equal_length(..., len = c(1L, 10L))
... |
A set of named or unnamed vector generators. |
len |
Length of the generated vectors. If |
A quickcheck_generator object.
equal_length(integer_(), double_()) %>% show_example() equal_length(a = logical_(), b = character_(), len = 5L) %>% show_example()equal_length(integer_(), double_()) %>% show_example() equal_length(a = logical_(), b = character_(), len = 5L) %>% show_example()
A generator for factor vectors.
factor_(len = c(1L, 10L), any_na = FALSE)factor_(len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
A quickcheck_generator object.
factor_() %>% show_example() factor_(len = 10L, any_na = TRUE) %>% show_example()factor_() %>% show_example() factor_(len = 10L, any_na = TRUE) %>% show_example()
Generate flat lists with all values coming from a single generator. In a flat list all items will be scalars.
flat_list_of(generator, len = c(1L, 10L))flat_list_of(generator, len = c(1L, 10L))
generator |
A |
len |
Length of the generated vectors. If |
A quickcheck_generator object.
flat_list_of(integer_(), len = 10L) %>% show_example()flat_list_of(integer_(), len = 10L) %>% show_example()
Test properties of a function
for_all( ..., property, tests = getOption("quickcheck.tests", 100L), shrinks = getOption("quickcheck.shrinks", 100L), discards = getOption("quickcheck.discards", 100L) )for_all( ..., property, tests = getOption("quickcheck.tests", 100L), shrinks = getOption("quickcheck.shrinks", 100L), discards = getOption("quickcheck.discards", 100L) )
... |
Named generators |
property |
A function which takes values from from the generator and calls an expectation on it. This function must have parameters matching the generator names. |
tests |
The number of tests to run. |
shrinks |
The maximum number of shrinks to run when shrinking a value to find the smallest counterexample. |
discards |
The maximum number of discards to permit when running the property. |
A testthat expectation object.
for_all( a = numeric_(len = 1L), b = numeric_(len = 1L), property = function(a, b) testthat::expect_equal(a + b, b + a), tests = 10L )for_all( a = numeric_(len = 1L), b = numeric_(len = 1L), property = function(a, b) testthat::expect_equal(a + b, b + a), tests = 10L )
Convert a hedgehog generator to a quickcheck generator
from_hedgehog(generator)from_hedgehog(generator)
generator |
A |
A quickcheck_generator object.
is_even <- function(a) a %% 2L == 0L gen_powers_of_two <- hedgehog::gen.element(1:10) %>% hedgehog::gen.with(function(a) 2 ^ a) for_all( a = from_hedgehog(gen_powers_of_two), property = function(a) is_even(a) %>% testthat::expect_true() )is_even <- function(a) a %% 2L == 0L gen_powers_of_two <- hedgehog::gen.element(1:10) %>% hedgehog::gen.with(function(a) 2 ^ a) for_all( a = from_hedgehog(gen_powers_of_two), property = function(a) is_even(a) %>% testthat::expect_true() )
A set of generators for hms vectors.
hms_(len = c(1L, 10L), any_na = FALSE) hms_bounded(left, right, len = c(1L, 10L), any_na = FALSE) hms_left_bounded(left, len = c(1L, 10L), any_na = FALSE) hms_right_bounded(right, len = c(1L, 10L), any_na = FALSE)hms_(len = c(1L, 10L), any_na = FALSE) hms_bounded(left, right, len = c(1L, 10L), any_na = FALSE) hms_left_bounded(left, len = c(1L, 10L), any_na = FALSE) hms_right_bounded(right, len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
left |
The minimum possible value for generated numbers, inclusive. |
right |
The maximum possible value for generated numbers, inclusive. |
A quickcheck_generator object.
hms_() %>% show_example() hms_bounded( left = hms::as_hms("00:00:00"), right = hms::as_hms("12:00:00") ) %>% show_example() hms_(len = 10L, any_na = TRUE) %>% show_example()hms_() %>% show_example() hms_bounded( left = hms::as_hms("00:00:00"), right = hms::as_hms("12:00:00") ) %>% show_example() hms_(len = 10L, any_na = TRUE) %>% show_example()
A set of generators for integer vectors.
integer_(len = c(1L, 10L), any_na = FALSE, big_int = FALSE) integer_bounded(left, right, len = c(1L, 10L), any_na = FALSE) integer_left_bounded(left, len = c(1L, 10L), any_na = FALSE, big_int = FALSE) integer_right_bounded(right, len = c(1L, 10L), any_na = FALSE, big_int = FALSE) integer_positive(len = c(1L, 10L), any_na = FALSE, big_int = FALSE) integer_negative(len = c(1L, 10L), any_na = FALSE, big_int = FALSE)integer_(len = c(1L, 10L), any_na = FALSE, big_int = FALSE) integer_bounded(left, right, len = c(1L, 10L), any_na = FALSE) integer_left_bounded(left, len = c(1L, 10L), any_na = FALSE, big_int = FALSE) integer_right_bounded(right, len = c(1L, 10L), any_na = FALSE, big_int = FALSE) integer_positive(len = c(1L, 10L), any_na = FALSE, big_int = FALSE) integer_negative(len = c(1L, 10L), any_na = FALSE, big_int = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
big_int |
Should integers near the maximum size be included? This may cause problems because if the result of a computation results in an integer larger than the maximum it will be silently coerced it to a double. |
left |
The minimum possible value for generated numbers, inclusive. |
right |
The maximum possible value for generated numbers, inclusive. |
A quickcheck_generator object.
integer_() %>% show_example() integer_(big_int = TRUE) %>% show_example() integer_bounded(left = -5L, right = 5L) %>% show_example() integer_(len = 10L, any_na = TRUE) %>% show_example()integer_() %>% show_example() integer_(big_int = TRUE) %>% show_example() integer_bounded(left = -5L, right = 5L) %>% show_example() integer_(len = 10L, any_na = TRUE) %>% show_example()
Generate lists with contents corresponding to the values generated by the input generators.
list_(...)list_(...)
... |
A set of named or unnamed generators. |
A quickcheck_generator object.
list_(integer_(), logical_()) %>% show_example() list_(a = any_vector(), b = any_vector()) %>% show_example()list_(integer_(), logical_()) %>% show_example() list_(a = any_vector(), b = any_vector()) %>% show_example()
Generate lists with all values coming from a single generator.
list_of(generator, len = c(1L, 10L))list_of(generator, len = c(1L, 10L))
generator |
A |
len |
Length of the generated vectors. If |
A quickcheck_generator object.
list_of(integer_(), len = 10L) %>% show_example()list_of(integer_(), len = 10L) %>% show_example()
A generator for logical vectors.
logical_(len = c(1L, 10L), any_na = FALSE)logical_(len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
A quickcheck_generator object.
logical_() %>% show_example() logical_(len = 10L, any_na = TRUE) %>% show_example()logical_() %>% show_example() logical_(len = 10L, any_na = TRUE) %>% show_example()
A set of generators for numeric vectors. Numeric vectors can be either integer or double vectors.
numeric_(len = c(1L, 10L), any_na = FALSE, big_num = FALSE) numeric_bounded(left, right, len = c(1L, 10L), any_na = FALSE) numeric_left_bounded(left, len = c(1L, 10L), any_na = FALSE, big_num = FALSE) numeric_right_bounded(right, len = c(1L, 10L), any_na = FALSE, big_num = FALSE) numeric_positive(len = c(1L, 10L), any_na = FALSE, big_num = FALSE) numeric_negative(len = c(1L, 10L), any_na = FALSE, big_num = FALSE)numeric_(len = c(1L, 10L), any_na = FALSE, big_num = FALSE) numeric_bounded(left, right, len = c(1L, 10L), any_na = FALSE) numeric_left_bounded(left, len = c(1L, 10L), any_na = FALSE, big_num = FALSE) numeric_right_bounded(right, len = c(1L, 10L), any_na = FALSE, big_num = FALSE) numeric_positive(len = c(1L, 10L), any_na = FALSE, big_num = FALSE) numeric_negative(len = c(1L, 10L), any_na = FALSE, big_num = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
big_num |
Should integers or doubles near the
maximum size be included? This may cause problems because
if the result of a computation results in a number
larger than the maximum an integer will be silently
coerced to a double and a double will return |
left |
The minimum possible value for generated numbers, inclusive. |
right |
The maximum possible value for generated numbers, inclusive. |
A quickcheck_generator object.
numeric_() %>% show_example() numeric_(big_num = TRUE) %>% show_example() numeric_bounded(left = -5L, right = 5L) %>% show_example() numeric_(len = 10L, any_na = TRUE) %>% show_example()numeric_() %>% show_example() numeric_(big_num = TRUE) %>% show_example() numeric_bounded(left = -5L, right = 5L) %>% show_example() numeric_(len = 10L, any_na = TRUE) %>% show_example()
Randomly choose between generators
one_of(..., prob = NULL)one_of(..., prob = NULL)
... |
A set of unnamed generators. |
prob |
A vector of probability weights for obtaining the elements of the vector being sampled. |
A quickcheck_generator object.
one_of(integer_(), character_()) %>% show_example() one_of(constant(NULL), logical_(), prob = c(0.1, 0.9)) %>% show_example()one_of(integer_(), character_()) %>% show_example() one_of(constant(NULL), logical_(), prob = c(0.1, 0.9)) %>% show_example()
A set of generators for POSIXct vectors.
posixct_(len = c(1L, 10L), any_na = FALSE) posixct_bounded(left, right, len = c(1L, 10L), any_na = FALSE) posixct_left_bounded(left, len = c(1L, 10L), any_na = FALSE) posixct_right_bounded(right, len = c(1L, 10L), any_na = FALSE)posixct_(len = c(1L, 10L), any_na = FALSE) posixct_bounded(left, right, len = c(1L, 10L), any_na = FALSE) posixct_left_bounded(left, len = c(1L, 10L), any_na = FALSE) posixct_right_bounded(right, len = c(1L, 10L), any_na = FALSE)
len |
Length of the generated vectors. If |
any_na |
Whether |
left |
The minimum possible value for generated numbers, inclusive. |
right |
The maximum possible value for generated numbers, inclusive. |
A quickcheck_generator object.
posixct_() %>% show_example() posixct_bounded( left = as.POSIXct("2020-01-01 00:00:00"), right = as.POSIXct("2021-01-01 00:00:00") ) %>% show_example() posixct_(len = 10L, any_na = TRUE) %>% show_example()posixct_() %>% show_example() posixct_bounded( left = as.POSIXct("2020-01-01 00:00:00"), right = as.POSIXct("2021-01-01 00:00:00") ) %>% show_example() posixct_(len = 10L, any_na = TRUE) %>% show_example()
Repeatedly test properties of a function
repeat_test(property, tests = getOption("quickcheck.tests", 100L))repeat_test(property, tests = getOption("quickcheck.tests", 100L))
property |
A function with no parameters which includes an expectation. |
tests |
The number of tests to run. |
A testthat expectation object.
repeat_test( property = function() { num <- stats::runif(1, min = 0, max = 10) testthat::expect_true(num >= 0 && num <= 10) } )repeat_test( property = function() { num <- stats::runif(1, min = 0, max = 10) testthat::expect_true(num >= 0 && num <= 10) } )
Show an example output of a generator
show_example(generator)show_example(generator)
generator |
A |
An example output produced by the generator.
logical_() %>% show_example()logical_() %>% show_example()
Construct tibble generators in a similar way to tibble::tibble.
tibble_(..., rows = c(1L, 10L))tibble_(..., rows = c(1L, 10L))
... |
A set of name-value pairs with the values being vector generators. |
rows |
Number of rows of the generated data frame.
If |
A quickcheck_generator object.
tibble_(a = integer_()) %>% show_example() tibble_(a = integer_(), b = character_(), rows = 5L) %>% show_example()tibble_(a = integer_()) %>% show_example() tibble_(a = integer_(), b = character_(), rows = 5L) %>% show_example()
Random tibble generator
tibble_of(..., rows = c(1L, 10L), cols = c(1L, 10L))tibble_of(..., rows = c(1L, 10L), cols = c(1L, 10L))
... |
A set of unnamed generators. The generated tibbles will be built with random combinations of these generators. |
rows |
Number of rows of the generated data frame.
If |
cols |
Number of columns of the generated data frame.
If |
A quickcheck_generator object.
tibble_of(logical_(), date_()) %>% show_example() tibble_of(any_atomic(), rows = 10L, cols = 5L) %>% show_example()tibble_of(logical_(), date_()) %>% show_example() tibble_of(any_atomic(), rows = 10L, cols = 5L) %>% show_example()