1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-12 07:41:58 +02:00

(v1.6.0.9065) unit tests

This commit is contained in:
2021-05-24 11:01:32 +02:00
parent 4fbf9e1720
commit e5599bc694
22 changed files with 126 additions and 133 deletions

View File

@ -22,34 +22,32 @@
# Visit our website for the full manual and a complete tutorial about #
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
expect_equal(AMR:::percentage(0.25), "25%")
expect_equal(AMR:::percentage(0.5), "50%")
expect_equal(AMR:::percentage(0.500, digits = 1), "50.0%")
expect_equal(AMR:::percentage(0.1234), "12.3%")
# round up 0.5
# round up 0.5
expect_equal(AMR:::percentage(0.0054), "0.5%")
expect_equal(AMR:::percentage(0.0055), "0.6%")
expect_equal(AMR:::strrep("A", 5), "AAAAA")
expect_equal(AMR:::strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))
expect_equal(AMR:::trimws(" test "), "test")
expect_equal(AMR:::trimws(" test ", "l"), "test ")
expect_equal(AMR:::trimws(" test ", "r"), " test")
expect_warning(AMR:::generate_warning_abs_missing(c("AMP", "AMX")))
expect_warning(AMR:::generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
expect_warning(AMR:::get_column_abx(example_isolates, hard_dependencies = "FUS"))
expect_message(AMR:::get_column_abx(example_isolates, soft_dependencies = "FUS"))
if (AMR:::pkg_is_available("dplyr")) {
if (AMR:::pkg_is_available("dplyr")) {
expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
}
# we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this:
if (AMR:::pkg_is_available("dplyr")) {
expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id)))
}
}
# we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this:
if (AMR:::pkg_is_available("dplyr")) {
expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id)))
}