install logo correctly

This commit is contained in:
Jared Knowles
2020-07-06 11:48:10 -04:00
parent f5f288974f
commit 20f65a7126
32 changed files with 582 additions and 95 deletions
+53
View File
@@ -0,0 +1,53 @@
# Test utils
context("Test Utilities - Safe Max")
test_that("safe_max excludes NAs", {
samp_a <- c(1:10, NA)
expect_equal(safe_max(samp_a), 10)
expect_equal(safe_max(samp_a), max(samp_a, na.rm = TRUE))
expect_equal(safe_max(c("cat", "box", "dog")), "dog")
expect_equal(safe_max(c("cat", "box", "dog")), max(c("cat", "box", "dog"), na.rm = TRUE))
})
test_that("safe_max handles all NAs", {
expect_equal(safe_max(rep(NA, 100)), NA)
expect_equal(safe_max(NULL), NA)
})
context("Test Utilities - Pretty Per")
test_that("pretty_per respects rounding", {
expect_identical(pretty_per(0.2), "20.0%")
expect_identical(pretty_per(0.2432522), "24.3%")
expect_identical(pretty_per(0.2432522, ndigit = 3), "24.325%")
})
test_that("pretty_per handles NAs", {
expect_equivalent(pretty_per(rep(NA, 5)), c("-", "-", "-", "-", "-"))
})
test_that("pretty_per deals with large numbers", {
expect_message(pretty_per(c(0.2, 0.5, 0.1, 110)))
})
context("Test Utilities - NA Zero")
test_that("Function works when no NAs present", {
expect_equivalent(na_zero(1:10), 1:10)
expect_equivalent(na_zero(letters), letters)
})
test_that("Function subs out NAs in numeric vectors with 0", {
expect_equivalent(na_zero(c(1:10, NA)), c(1:10, 0))
})
context("Test Utilities - Pretty Count")