1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 21:22:01 +02:00

extra unit tests, add row.names to freq

This commit is contained in:
2018-06-19 15:20:14 +02:00
parent bdc860e29c
commit 4a027f3c34
8 changed files with 77 additions and 25 deletions

View File

@ -2,10 +2,19 @@ context("atc.R")
test_that("atc_property works", {
expect_equal(tolower(atc_property("J01CA04", property = "Name")), "amoxicillin")
expect_equivalent(atc_property("J01CA04", "DDD"), 1)
expect_equal(length(atc_property("J01CA04", property = "Groups")), 4)
expect_equal(atc_property("J01CA04", property = "unit"), "g")
expect_equal(atc_property("J01CA04", property = "DDD"),
atc_ddd("J01CA04"))
expect_identical(atc_property("J01CA04", property = "Groups"),
atc_groups("J01CA04"))
expect_warning(atc_property("ABCDEFG", property = "DDD"))
expect_error(atc_property("J01CA04", property = c(1:5)))
expect_error(atc_property("J01CA04", administration = c(1:5)))
expect_error(atc_property("J01CA04", property = "test"))
expect_error(atc_property("J01CA04", property = "test", administration = c(1:5)))
})
test_that("abname works", {
@ -13,8 +22,15 @@ test_that("abname works", {
expect_equal(abname(c("AMOX", "GENT")), c("Amoxicillin", "Gentamicin"))
expect_equal(abname(c("AMOX+GENT")), "Amoxicillin + gentamicin")
expect_equal(abname("AMOX", from = 'umcg'), "Amoxicillin")
expect_equal(abname("amox", from = 'molis'), "Amoxicillin")
expect_equal(abname("amox", from = 'molis', tolower = TRUE), "amoxicillin")
expect_equal(abname("J01CA04", from = 'atc'), "Amoxicillin")
expect_equal(abname("AMOX", to = 'atc'), "J01CA04")
expect_equal(abname("AMOX en GENT"), "Amoxicillin + gentamicin")
expect_error(abname("AMOX", to = c(1:3)))
expect_error(abname("AMOX", to = "test"))
expect_warning(abname("TEST
"))
expect_warning(abname("AMOX or GENT"))
})
test_that("guess_atc works", {

View File

@ -6,9 +6,18 @@ test_that("guess_bactid works", {
c("ESCCOL", "HAEINF"))
expect_equal(guess_bactid("Escherichia coli"), "ESCCOL")
expect_equal(guess_bactid("P. aer"), "PSEAER") # not Pasteurella aerogenes
expect_equal(guess_bactid("Negative rods"), "GNR")
expect_equal(guess_bactid("MRSE"), "STAEPI")
expect_equal(guess_bactid("VRE"), "ENC")
expect_equal(guess_bactid("MRPA"), "PSEAER")
expect_equal(guess_bactid("PISP"), "STCPNE")
expect_equal(guess_bactid("PRSP"), "STCPNE")
expect_equal(guess_bactid("VISP"), "STCPNE")
expect_equal(guess_bactid("VRSP"), "STCPNE")
expect_identical(
guess_bactid(c("stau",
"STAU",