tests/testthat/test_factor.R

context("Test factor functions")

test_that("as_numeric_factor() returns correct data.", {

  months  <- c(1:12)
  factors <- factor(4:6, levels = months)
  tested  <- as_numeric_factor(factors)

  ## Type check
  expect_is(tested, "numeric")

  ## Dimention check
  expect_equal(tested, 4:6)
})
five-dots/rutils documentation built on April 8, 2020, 12:49 p.m.