stRoke/tests/testthat/test-cpr_tools.R

26 lines
1.1 KiB
R
Raw Normal View History

2022-09-26 13:59:05 +02:00
testthat::test_that("cpr_check() works for vectors, giving logicals", {
2022-09-22 14:20:46 +02:00
result <- cpr_check(c("2310450637", "010115-4000", "0101896000","010189-3000","300450-1030","010150-4021"))
2022-09-26 13:59:05 +02:00
testthat::expect_equal(any(result), TRUE)
testthat::expect_type(result, "logical")
testthat::expect_equal(result[2], FALSE)
2022-09-22 14:20:46 +02:00
})
################################################################################
2022-09-26 13:59:05 +02:00
testthat::test_that("cpr_dob() works for vectors, giving logicals", {
2022-09-22 14:20:46 +02:00
result <- cpr_dob(c("2310450637", "010115-4000", "0101896000","010189-3000","300450-1030","010150-4021"))
2022-09-26 13:59:05 +02:00
testthat::expect_type(result, "double")
testthat::expect_s3_class(result, "Date")
testthat::expect_length(result, 6)
2022-09-22 14:20:46 +02:00
})
2022-09-22 15:45:40 +02:00
################################################################################
2022-09-26 13:59:05 +02:00
testthat::test_that("cpr_female() works for vectors, giving logicals", {
2022-09-22 15:45:40 +02:00
result <- cpr_female(c("2310450637", "010115-4000", "0101896000","010189-3000","300450-1030","010150-4021"))
2022-09-26 13:59:05 +02:00
testthat::expect_type(result, "logical")
testthat::expect_length(result, 6)
testthat::expect_equal(result[2], TRUE)
2022-09-22 15:45:40 +02:00
})
2022-09-22 14:20:46 +02:00
################################################################################