Skip to content

Commit

Permalink
incorporate another test scenario from @BlairCooper
Browse files Browse the repository at this point in the history
  • Loading branch information
wibeasley committed Jul 15, 2023
1 parent 16fbe86 commit 5f75564
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ This will help extract forms from longitudinal & repeating projects.
* `validate_repeat_instance()`
* `validate_no_logical()`
* `redcap_read()` checks the `event` parameter and throws an error if a value is not recognized, or the project is not longitudinal (#493)
* The regex in `regex_named_captures()` is forgiving if there's an unnecessary leading space (@BlairCooper, #495)
* The regex in `regex_named_captures()` is forgiving if there's an unnecessary leading space (@BlairCooper, #495, #501)
Version 1.1.0 (released 2022-08-10)
==========================================================
Expand Down
31 changes: 31 additions & 0 deletions tests/testthat/test-metadata-utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,37 @@ test_that("checkbox choices -commas in labels", {
expect_equal(ds_expected, label = "no trailing spaces:")
})

test_that("checkbox choices -digits only", {
ds_expected <- # datapasta::tribble_paste(ds_expected)
tibble::tribble(
~id , ~label,
"1" , "1",
"2" , "2",
"3" , "3",
"4" , "4"
)

# well-behaved
"1, 1 | 2, 2 | 3, 3 | 4, 4" |>
checkbox_choices() |>
expect_equal(ds_expected, label = "well-behaved:")

# missing leading space
"1, 1 | 2,2 | 3, 3 | 4, 4" |>
checkbox_choices() |>
expect_equal(ds_expected, label = "missing leading space:")

# missing trailing spaces
"1, 1 | 2, 2| 3, 3| 4, 4" |>
checkbox_choices() |>
expect_equal(ds_expected, label = "no leading spaces:")

# extra lines
"|1, 1 | 2, 2 | 3, 3 || 4, 4| |" |>
checkbox_choices() |>
expect_equal(ds_expected, label = "well-behaved:")
})

test_that("checkbox choices with special characters", {
ds_expected <- # datapasta::tribble_paste(ds_expected)
tibble::tribble(
Expand Down

0 comments on commit 5f75564

Please sign in to comment.