This commit is contained in:
dr. M.S. (Matthijs) Berends 2022-09-18 14:00:29 +02:00
parent 0e6fb05aca
commit 835cf7c32d
6 changed files with 18 additions and 12 deletions

View File

@ -1,5 +1,5 @@
Package: AMR
Version: 1.8.1.9052
Version: 1.8.1.9055
Date: 2022-09-18
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)

View File

@ -1,4 +1,4 @@
# AMR 1.8.1.9052
# AMR 1.8.1.9055
This version will eventually become v2.0! We're happy to reach a new major milestone soon!

View File

@ -1489,8 +1489,4 @@ if (getRversion() < "4.0.0") {
}
}
# for tinytest unit tests, that call AMR:::xxx():
strrep <- strrep
# nolint end

View File

@ -31,11 +31,12 @@ expect_equal(AMR:::percentage(0.1234), "12.3%")
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")
# test functions on all R versions - R < 3.3 did not contain these
expect_equal(strrep("A", 5), "AAAAA")
expect_equal(strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))
expect_equal(trimws(" test "), "test")
expect_equal(trimws(" test ", "l"), "test ")
expect_equal(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))

View File

@ -36,7 +36,7 @@ expect_equal(
)
)
MOs_mentioned <- unique(AMR:::EUCAST_RULES_DF$this_value)
MOs_mentioned <- sort(AMR:::trimws(unlist(strsplit(MOs_mentioned[!AMR:::is_valid_regex(MOs_mentioned)], ",", fixed = TRUE))))
MOs_mentioned <- sort(trimws(unlist(strsplit(MOs_mentioned[!AMR:::is_valid_regex(MOs_mentioned)], ",", fixed = TRUE))))
MOs_test <- suppressWarnings(suppressMessages(mo_name(MOs_mentioned)))
expect_true(length(MOs_mentioned[MOs_test != MOs_mentioned]) == 0)

View File

@ -23,13 +23,22 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
# we use {tinytest} instead of {testthat} because it does not rely on recent R versions - we want to test on R >= 3.0.
# test only on GitHub Actions and at home - not on CRAN as tests are lengthy
if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) {
# env var 'R_LIBS_USER' got overwritten during 'R CMD check' in GitHub Actions, so:
.libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths()))
if (AMR:::pkg_is_available("tinytest", also_load = TRUE)) {
library(AMR)
# set language
set_AMR_locale("English")
# get trimws() and strrep() if on old R
if (getRversion() < "3.3.0") {
trimws <- AMR:::trimws
strrep <- AMR:::strrep
}
# start the unit tests
out <- test_package("AMR",
testdir = ifelse(dir.exists("inst/tinytest"),
"inst/tinytest",