-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🥇 --------- Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
- Loading branch information
1 parent
cab0e41
commit dd1c67c
Showing
6 changed files
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
test_that("default_cdisc_join_keys is assigned in package environment", { | ||
expect_true(exists("default_cdisc_join_keys")) | ||
expect_gt(length(default_cdisc_join_keys), 0) | ||
testthat::test_that("default_cdisc_join_keys is assigned in package environment", { | ||
testthat::expect_true(exists("default_cdisc_join_keys")) | ||
testthat::expect_gt(length(default_cdisc_join_keys), 0) | ||
}) | ||
|
||
test_that("default_cdisc_join_keys subsetting of datasets with parent is valid", { | ||
testthat::test_that("default_cdisc_join_keys subsetting of datasets with parent is valid", { | ||
# indirect test to build_cdisc_join_keys | ||
ds <- c("ADTTE", "ADSL") | ||
result <- default_cdisc_join_keys[ds] | ||
expect_length(result, 2) | ||
expect_length(parents(result), 1) | ||
testthat::expect_length(result, 2) | ||
testthat::expect_length(parents(result), 1) | ||
}) | ||
|
||
test_that("default_cdisc_join_keys subsetting of dataset without parent contains parent", { | ||
testthat::test_that("default_cdisc_join_keys subsetting of dataset without parent contains parent", { | ||
# indirect test to build_cdisc_join_keys | ||
ds <- c("ADTTE", "ADEX", "ADRS") | ||
result <- default_cdisc_join_keys[ds] | ||
expect_length(result, 4) | ||
expect_length(parents(result), 3) | ||
testthat::expect_length(result, 4) | ||
testthat::expect_length(parents(result), 3) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,83 @@ | ||
test_that("join_key throws error with NULL keys", { | ||
expect_error(join_key("d1", "d2", keys = NULL)) | ||
testthat::test_that("join_key throws error with NULL keys", { | ||
testthat::expect_error(join_key("d1", "d2", keys = NULL)) | ||
}) | ||
|
||
test_that("join_key throws error with NA keys", { | ||
expect_error(join_key("d1", "d2", keys = NA)) | ||
expect_error(join_key("d1", "d2", keys = c("X" = "A", "B", NA))) | ||
testthat::test_that("join_key throws error with NA keys", { | ||
testthat::expect_error(join_key("d1", "d2", keys = NA)) | ||
testthat::expect_error(join_key("d1", "d2", keys = c("X" = "A", "B", NA))) | ||
}) | ||
|
||
test_that("join_key throws error with numeric keys", { | ||
expect_error(join_key("d1", "d2", keys = 1:10)) | ||
testthat::test_that("join_key throws error with numeric keys", { | ||
testthat::expect_error(join_key("d1", "d2", keys = 1:10)) | ||
}) | ||
|
||
test_that("join_key throws error with data keys", { | ||
expect_error(join_key("d1", "d2", keys = Sys.time() + seq(1, 5))) | ||
testthat::test_that("join_key throws error with data keys", { | ||
testthat::expect_error(join_key("d1", "d2", keys = Sys.time() + seq(1, 5))) | ||
}) | ||
|
||
test_that("join_key throws error with invalid duplicate names in keys/values", { | ||
expect_error(join_key("d1", "d2", keys = c("A" = "A", "A" = "B"))) | ||
expect_error(join_key("d1", "d2", keys = c("C" = "A", "D" = "A"))) | ||
testthat::test_that("join_key throws error with invalid duplicate names in keys/values", { | ||
testthat::expect_error(join_key("d1", "d2", keys = c("A" = "A", "A" = "B"))) | ||
testthat::expect_error(join_key("d1", "d2", keys = c("C" = "A", "D" = "A"))) | ||
}) | ||
|
||
test_that("join_key throws error with invalid primary keys (names != keys)", { | ||
expect_error(join_key("d1", "d1", keys = c("B" = "A", "A" = "B"))) | ||
expect_error(join_key("d1", keys = c("B" = "A", "A" = "B"))) | ||
testthat::test_that("join_key throws error with invalid primary keys (names != keys)", { | ||
testthat::expect_error(join_key("d1", "d1", keys = c("B" = "A", "A" = "B"))) | ||
testthat::expect_error(join_key("d1", keys = c("B" = "A", "A" = "B"))) | ||
}) | ||
|
||
test_that("join_key throws error with invalid dataset arguments", { | ||
testthat::test_that("join_key throws error with invalid dataset arguments", { | ||
# missing | ||
expect_error(join_key("d1", as.character(NA), keys = c("A" = "B", "C" = "D"))) | ||
testthat::expect_error(join_key("d1", as.character(NA), keys = c("A" = "B", "C" = "D"))) | ||
# invalid type | ||
expect_error(join_key("d1", 5, keys = c("A" = "B", "C" = "D"))) | ||
testthat::expect_error(join_key("d1", 5, keys = c("A" = "B", "C" = "D"))) | ||
# invalid length | ||
expect_error(join_key("d1", c("d1", "d2"), keys = c("A" = "B", "C" = "D"))) | ||
testthat::expect_error(join_key("d1", c("d1", "d2"), keys = c("A" = "B", "C" = "D"))) | ||
}) | ||
|
||
test_that("join_key does not throw error with valid arguments", { | ||
testthat::test_that("join_key does not throw error with valid arguments", { | ||
# keys of length 0 | ||
expect_silent(join_key("d1", "d2", keys = character(0))) | ||
testthat::expect_silent(join_key("d1", "d2", keys = character(0))) | ||
# keys of length 1 | ||
expect_silent(join_key("d1", "d2", keys = c("A" = "B"))) | ||
testthat::expect_silent(join_key("d1", "d2", keys = c("A" = "B"))) | ||
# keys of length > 1 | ||
expect_silent(join_key("d1", "d2", keys = c("A" = "B", "C" = "D"))) | ||
testthat::expect_silent(join_key("d1", "d2", keys = c("A" = "B", "C" = "D"))) | ||
# dataset_1 and dataset_2 can be the same if keys match | ||
expect_silent(join_key("d1", "d1", keys = c("A" = "A", "B" = "B"))) | ||
testthat::expect_silent(join_key("d1", "d1", keys = c("A" = "A", "B" = "B"))) | ||
|
||
expect_silent(join_key("d1", keys = c("A" = "A", "B" = "B"))) | ||
testthat::expect_silent(join_key("d1", keys = c("A" = "A", "B" = "B"))) | ||
}) | ||
|
||
test_that("join_key will fill empty names with value", { | ||
testthat::test_that("join_key will fill empty names with value", { | ||
# keys of length 0 | ||
jk <- join_key("d1", "d2", keys = c("A" = "B", "C")) | ||
expect_identical(jk[[1]][[1]], stats::setNames(c("B", "C"), c("A", "C"))) | ||
testthat::expect_identical(jk[[1]][[1]], stats::setNames(c("B", "C"), c("A", "C"))) | ||
|
||
jk <- join_key("d1", "d2", keys = c("B", "C")) | ||
expect_identical(jk[[1]][[1]], stats::setNames(c("B", "C"), c("B", "C"))) | ||
testthat::expect_identical(jk[[1]][[1]], stats::setNames(c("B", "C"), c("B", "C"))) | ||
}) | ||
|
||
test_that("join_key will fill empty values with name", { | ||
testthat::test_that("join_key will fill empty values with name", { | ||
# keys of length 0 | ||
jk <- join_key("d1", "d2", keys = c("A" = "B", "C" = "")) | ||
expect_identical(jk[[1]][[1]], stats::setNames(c("B", "C"), c("A", "C"))) | ||
testthat::expect_identical(jk[[1]][[1]], stats::setNames(c("B", "C"), c("A", "C"))) | ||
|
||
jk <- join_key("d1", "d2", keys = c("B", "C" = "")) | ||
expect_identical(jk[[1]][[1]], stats::setNames(c("B", "C"), c("B", "C"))) | ||
testthat::expect_identical(jk[[1]][[1]], stats::setNames(c("B", "C"), c("B", "C"))) | ||
}) | ||
|
||
test_that("join_key ignores empty name/value on keys if it has other keys", { | ||
expect_message(jk <- join_key("d1", "d2", keys = c("A" = "B", "")), "are ignored") | ||
expect_identical(jk[[1]][[1]], stats::setNames(c("B"), c("A"))) | ||
testthat::test_that("join_key ignores empty name/value on keys if it has other keys", { | ||
testthat::expect_message(jk <- join_key("d1", "d2", keys = c("A" = "B", "")), "are ignored") | ||
testthat::expect_identical(jk[[1]][[1]], stats::setNames(c("B"), c("A"))) | ||
|
||
expect_message(jk <- join_key("d1", "d2", keys = c("B", "")), "are ignored") | ||
expect_identical(jk[[1]][[1]], stats::setNames(c("B"), c("B"))) | ||
testthat::expect_message(jk <- join_key("d1", "d2", keys = c("B", "")), "are ignored") | ||
testthat::expect_identical(jk[[1]][[1]], stats::setNames(c("B"), c("B"))) | ||
}) | ||
|
||
test_that("join_key sets key as character(0) when keys are all all empty strings", { | ||
testthat::test_that("join_key sets key as character(0) when keys are all all empty strings", { | ||
# invalid types | ||
jk <- join_key("d1", "d2", keys = c("", "", "", "")) | ||
expect_length(jk[[1]][[1]], 0) | ||
testthat::expect_length(jk[[1]][[1]], 0) | ||
|
||
jk2 <- join_key("d1", "d2", keys = c(" ", " ", " ", " ")) | ||
expect_length(jk2[[1]][[1]], 0) | ||
testthat::expect_length(jk2[[1]][[1]], 0) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters