tests/testthat/test-parse-a-columns.R

context("test_.parse_a_columns - unit tests")

test_that(".parse_a_columns returns expected tibble", {
  example <- tibble::tibble(
    "a_col" = c("1;2",
                "42",
                "37",
                "waa",
                "Y",
                "N",
                ".",
                "8"),
    "col_to_a" = c("A;D;P;N;foo",
                   "D;P;N;foo",
                   "P;N;foo",
                   "waa",
                   "N",
                   "N;D",
                   "P;A",
                   "8")
  )
  target <- tibble::tibble(
    "a_col" = c("1;2",
                "42",
                "37",
                "waa",
                "Y",
                "N",
                ".",
                "8"),
    "col_to_a" = c("A",
                   "D",
                   "P",
                   ".",
                   "N",
                   "D",
                   "A",
                   ".")
  )
  result <- .parse_a_columns(example, "col_to_a")
  expect_identical(result, target)
})
UW-GAC/wgsaparsr documentation built on Aug. 9, 2020, 5:50 a.m.