mirror of
https://github.com/msberends/AMR.git
synced 2025-12-15 12:30:22 +01:00
add tests using testthat
This commit is contained in:
23
tests/testthat/test-first_isolates.R
Normal file
23
tests/testthat/test-first_isolates.R
Normal file
@@ -0,0 +1,23 @@
|
||||
context("first_isolates.R")
|
||||
|
||||
test_that("keyantibiotics work", {
|
||||
expect_equal(length(key_antibiotics(septic_patients, info = FALSE)), nrow(septic_patients))
|
||||
expect_true(key_antibiotics_equal("SSS", "SSS"))
|
||||
expect_true(key_antibiotics_equal("SSS", "SIS", ignore_I = TRUE))
|
||||
expect_false(key_antibiotics_equal("SSS", "SIS", ignore_I = FALSE))
|
||||
})
|
||||
|
||||
|
||||
test_that("guess_bactid works", {
|
||||
expect_equal(guess_bactid("E. coli"), "ESCCOL")
|
||||
expect_equal(guess_bactid("Escherichia coli"), "ESCCOL")
|
||||
})
|
||||
|
||||
test_that("first isolates work", {
|
||||
# septic_patients contains 1960 out of 2000 first isolates
|
||||
expect_equal(sum(first_isolate(septic_patients,
|
||||
"date",
|
||||
"patient_id",
|
||||
"bactid",
|
||||
info = FALSE)), 1960)
|
||||
})
|
||||
Reference in New Issue
Block a user