REDCapCAST/tests/testthat/test-utils.R

23 lines
682 B
R
Raw Permalink Normal View History

2023-07-04 16:03:06 +02:00
test_that("strsplitx works", {
expect_equal(2 * 2, 4)
2024-02-27 13:20:21 +01:00
test <- c("12 months follow-up", "3 steps", "mRS 6 weeks",
"Counting to 231 now")
expect_length(strsplitx(test, "[0-9]", type = "around")[[1]], 3)
2023-07-04 16:03:06 +02:00
2024-02-27 13:20:21 +01:00
expect_equal(strsplitx(test, "[0-9]", type = "classic")[[2]][1], "")
expect_length(strsplitx(test, "[0-9]", type = "classic")[[4]], 4)
2023-07-04 16:03:06 +02:00
2024-02-27 13:20:21 +01:00
expect_length(strsplitx(test, "[0-9]", type = "classic")[[4]], 4)
2023-07-04 16:03:06 +02:00
})
test_that("d2w works", {
2024-02-27 13:20:21 +01:00
expect_length(d2w(c(2:8, 21)), 8)
2023-07-04 16:03:06 +02:00
2024-02-27 13:20:21 +01:00
expect_equal(d2w(data.frame(2:7, 3:8, 1),
lang = "da",
neutrum = TRUE
)[1, 3], "et")
2023-07-04 16:03:06 +02:00
2024-02-27 13:20:21 +01:00
expect_equal(d2w(list(2:8, c(2, 6, 4, 23), 2), everything = T)[[2]][4], "two three")
2023-07-04 16:03:06 +02:00
})