tests/testthat/test_lload_llsave.R

context("Saving and loading")

test_that("saving and loading works", {
  a <- as_lvec(rnorm(100))
  dir <- tempfile()
  dir.create(dir)

  lsave(a, filename = file.path(dir, "test"))
  expect_true(file.exists(file.path(dir, "test.RDS")))
  expect_true(file.exists(file.path(dir, "test.00001.RDS")))

  b <- lload(file.path(dir, "test"))
  expect_that(as_rvec(b), equals(as_rvec(a)))

  b <- lload(file.path(dir, "test.RDS"))
  expect_that(as_rvec(b), equals(as_rvec(a)))

  lsave(a, filename = file.path(dir, "test.RDS"))
  expect_true(file.exists(file.path(dir, "test.RDS")))
  expect_true(file.exists(file.path(dir, "test.00001.RDS")))
})

Try the lvec package in your browser

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

lvec documentation built on May 24, 2018, 9:04 a.m.