tests/testthat/test-function-findColumnNumbersByMatchingPatterns.R

test_that("findColumnNumbersByMatchingPatterns() works", {

  f <- kwb.utils:::findColumnNumbersByMatchingPatterns

  expect_error(f())

  columnDescription <- list(
    x = list(match = "^x", colNumber = integer()),
    y = list(match = "^y", colNumber = 2)
  )
  
  y <- f(headerFields = c("x1", "x2", "y1", "y2"), columnDescription)
  
  expect_type(y, "list")
  expect_length(y, length(columnDescription))
  
  col_number_available <- sapply(y, function(xx) ! is.null(xx$colNumber))
  
  expect_true(all(col_number_available))
})
KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.