tests/testthat/test-separate_n.R

context("test-separate_n")

ds_in <-
  tibble::tibble(
    x = c("a,b,c", "a,b", "a,b,a,c", "A")
  )

ds_out <-
  tibble::tibble(
    new_var_1 = c("a", "a", "a", "A"),
    new_var_2 = c("b", "b", "b", NA),
    new_var_3 = c("c", NA, "a", NA),
    new_var_4 = c(NA, NA, "c", NA)
  )

test_that("seperate_n creates correct number of new variables", {
  expect_equal(
    separate_n(ds_in, x, sep = ","),
    ds_out
  )
})
Kidapt/keda documentation built on Nov. 23, 2019, 3:35 a.m.