tests/testthat/test-normal-zip.R

library(testthat)
library(campfin)

expect_detect <- function(object, pattern, negate = FALSE) {
  expect_true(all(str_detect(object, pattern, negate = negate)))
}

test_that("normal zip can convert and remove invalid", {
  x <- c(20015, "20015", "05661", NA, "00000", "XXXXX", "zip 20015")
  y <- normal_zip(x, na_rep = TRUE)
  expect_type(y, "character")
  expect_detect(na.omit(y), "[:alpha:]", negate = TRUE)
  expect_equal(count_na(y), 3)
})

Try the campfin package in your browser

Any scripts or data that you put into this service are public.

campfin documentation built on Oct. 20, 2023, 5:06 p.m.