unit test match funs
Gitea Organization/civilyticsR/pipeline/head This commit looks good

This commit is contained in:
Jared Knowles
2023-07-19 17:37:18 -04:00
parent a0b4abdb9e
commit 9acebb5133
8 changed files with 138 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
#' x <- LETTERS
#' y <- c(letters, LETTERS)
#' match_test(x, y)
#'
#'
context("Test Basic Output for match_test")
test_that("pretty_per respects rounding", {
x <- LETTERS
y <- c(letters, LETTERS)
testthat::expect_output(match_test(x, y))
})
+12
View File
@@ -47,6 +47,18 @@ test_that("Function subs out NAs in numeric vectors with 0", {
expect_equivalent(na_zero(c(1:10, NA)), c(1:10, 0))
})
# Test that na_sum works
test_that("NA Sum takes sum setting NA values to 0", {
expect_equivalent(na_sum(c(1:10, NA)), sum(1:10, 0))
expect_message(na_sum(c(1:10, NA)), "Taking a sum with missing values equal to 0, be careful 🐲")
})
test_that("na_sum fails with non-numerics", {
expect_error(na_sum(LETTERS))
expect_error(na_sum(as.factor(1:10)))
})
context("Test Utilities - Pretty Count")