tests/testthat/test_namedList.R

context("namedList")

test_that("namedList", {
  expect_equal(namedList(), setNames(vector("list", 0), nm = character()))
  expect_equal(namedList("a"), list(a=NULL))
  expect_equal(namedList(c("a", "b")), list(a=NULL, b=NULL))
  expect_equal(namedList(c("a", "b"), 1), list(a=1, b=1))
  f = function(x) x^2
  expect_equal(namedList(c("a", "b"), f(2)), list(a=4, b=4))
})

Try the BBmisc package in your browser

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

BBmisc documentation built on Sept. 29, 2022, 5:12 p.m.