tests/testthat/test-libjson-large.R

context("libjson Large strings")

test_that("escaping and parsing of special characters", {
  
  #create random strings
  mychars <- c('a', 'b', " ", '"', "\\", "\t", "\n", "'", "/", "#", "$");
  createstring <- function(length){
    paste(mychars[ceiling(runif(length, 0, length(mychars)))], collapse="")
  }  

  #try some very long strings
  for(i in 1:10){
    zz <- list(foo=createstring(1e5))
    expect_that(zz, equals(fromJSON(toJSON(zz))));
  }
  
});

Try the jsonlite package in your browser

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

jsonlite documentation built on July 9, 2023, 6:11 p.m.