tests/testthat/test-CRAN-field.R

library(testthat)
library(nc)
context("field")

test_that("field returns list", {
  int.pattern <- list("[0-9]+", as.integer)
  cell.sample.type <- list(
    cellType="[^ ]*?",
    "_",
    sampleName=list(
      "McGill",
      sampleID=int.pattern),
    dataType="Coverage|Peaks")
  computed <- nc::field(
    "track",
    " ",
    cell.sample.type,
    "|",
    "[^\n]+")
  expected <- list(
    "track",
    " ",
    list(track=list(
      cell.sample.type,
      "|",
      "[^\n]+")))
  expect_identical(computed, expected)
})

test_that("field errors for non-character first arg", {
  expect_error({
    field(identity, "bar", "sars")
  },
  "first argument of field must be character string (field name)",
  fixed=TRUE)
})

Try the nc package in your browser

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

nc documentation built on Sept. 1, 2023, 1:07 a.m.