tests/testthat/test-factors.R

test_that("multiplication works", {

  # issue #35
  color <- c("red", "blue", NA, "red", "white")
  color <- factor(color, levels=c("red", "blue"))
  color
  
  expect_no_error({
    color_str <- yyjsonr::write_json_str(color, factor = 'integer')
  })
  expect_identical('[1,2,null,1,null]', color_str)
  
  expect_no_error({
    color_str <- yyjsonr::write_json_str(color, factor = 'string')
  })
  expect_identical('["red","blue",null,"red",null]', color_str)

})

Try the yyjsonr package in your browser

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

yyjsonr documentation built on May 29, 2024, 3:01 a.m.