tests/testthat/test-data.R

# Work in progress. The book on R packages only mentions examples
# of tests for functions, so make sure to have a look at some test-
# directories of data-focused packages like covdata. Creating tests
# for data is very different from creating tests for functions.

# context("Datasets")

library(primer.data)
library(stringr)

cces
test_that("str_length is number of characters", {
 expect_equal(str_length("a"), 1)
 expect_equal(str_length("ab"), 2)
 expect_equal(str_length("abc"), 3)
})
test_that("no rows with same value for every variable", {
 expect_equal(str_length(factor("a")), 1)
 expect_equal(str_length(factor("ab")), 2)
 expect_equal(str_length(factor("abc")), 3)
})
PPBDS/primer.data documentation built on April 9, 2024, 5:36 p.m.