AMR/tests/testthat/test-ab_property.R

58 lines
2.9 KiB
R
Raw Normal View History

# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Analysis #
# #
2019-01-02 23:24:07 +01:00
# SOURCE #
# https://gitlab.com/msberends/AMR #
# #
# LICENCE #
2019-01-02 23:24:07 +01:00
# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
# #
2019-01-02 23:24:07 +01:00
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# #
# This R package was created for academic research and was publicly #
# released in the hope that it will be useful, but it comes WITHOUT #
# ANY WARRANTY OR LIABILITY. #
2019-04-05 18:47:39 +02:00
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
# ==================================================================== #
2019-05-10 16:44:59 +02:00
context("ab_property.R")
2018-03-27 17:43:42 +02:00
2019-05-10 16:44:59 +02:00
test_that("ab_property works", {
2018-04-30 16:24:11 +02:00
2019-05-10 16:44:59 +02:00
expect_identical(ab_name("AMX"), "Amoxicillin")
expect_identical(as.character(ab_atc("AMX")), "J01CA04")
expect_identical(ab_cid("AMX"), as.integer(33613))
2019-05-10 16:44:59 +02:00
expect_equal(class(ab_tradenames("AMX")), "character")
expect_equal(class(ab_tradenames(c("AMX", "AMX"))), "list")
2019-05-10 16:44:59 +02:00
expect_identical(ab_group("AMX"), "Beta-lactams/penicillins")
expect_identical(ab_atc_group1("AMX"), "Beta-lactam antibacterials, penicillins")
expect_identical(ab_atc_group2("AMX"), "Penicillins with extended spectrum")
2019-05-10 16:44:59 +02:00
expect_identical(ab_name("Fluclox"), "Flucloxacillin")
expect_identical(ab_name("fluklox"), "Flucloxacillin")
expect_identical(ab_name("floxapen"), "Flucloxacillin")
2019-10-11 17:21:02 +02:00
expect_identical(ab_name(21319), "Flucloxacillin")
2019-05-10 16:44:59 +02:00
expect_identical(ab_name("J01CF05"), "Flucloxacillin")
2019-05-10 16:44:59 +02:00
expect_identical(ab_ddd("AMX", "oral"), 1)
2019-10-11 17:21:02 +02:00
expect_identical(ab_ddd("AMX", "oral", units = TRUE), "g")
2019-05-10 16:44:59 +02:00
expect_identical(ab_ddd("AMX", "iv"), 1)
2019-10-11 17:21:02 +02:00
expect_identical(ab_ddd("AMX", "iv", units = TRUE), "g")
2019-01-29 00:06:50 +01:00
2019-05-10 16:44:59 +02:00
expect_identical(ab_name(x = c("AMC", "PLB")), c("Amoxicillin/clavulanic acid", "Polymyxin B"))
expect_identical(ab_name(x = c("AMC", "PLB"), tolower = TRUE),
c("amoxicillin/clavulanic acid", "polymyxin B"))
2019-05-16 21:20:00 +02:00
expect_equal(class(ab_info("AMX")), "list")
2019-05-10 16:44:59 +02:00
expect_error(ab_property("amox", "invalid property"))
expect_error(ab_name("amox", language = "INVALID"))
expect_output(print(ab_name("amox", language = NULL)))
})