New unit: RPR-Unit_tests, with sample test file and tests directory

This commit is contained in:
hyginn
2017-10-15 18:46:42 -04:00
parent c148d95071
commit 05958349cf
2 changed files with 219 additions and 0 deletions

32
tests/test_biCode.R Normal file
View File

@@ -0,0 +1,32 @@
# test_biCode.R
#
context("biCode() utility function tests") # A set of tests for some
# functionality
test_that("expected input is processed correctly", { # Related expectations
expect_equal(biCode("homo sapiens"), "HOMSA")
expect_equal(biCode("[homo sapiens neanderthaliensis]"), "HOMSA")
expect_equal(biCode(c("Phascolarctos cinereus", "Macropus rufus")),
c("PHACI", "MACRU"))
})
test_that("unexpected input is managed", {
expect_equal(biCode(""), ".....")
expect_equal(biCode(" "), ".....")
expect_equal(biCode("123 12"), ".....")
expect_equal(biCode("h sapiens"), "H..SA")
})
test_that("NA values are preserved", {
expect_true(is.na((biCode(NA))))
expect_equal(biCode(c("first", NA, "last")),
c("FIRST", NA, "LAST."))
})
test_that("Missing argument throws an error", {
expect_error(biCode(), "argument \"s\" is missing, with no default")
})
# [END]