tests/testthat/test-invert-named.R

library(testthat)
library(campfin)

test_that("names and values of a vector can be inverted", {
  x <- invert_named(c(name = "value"))
  expect_equal(names(x), "value")
  expect_equal(unname(x), "name")
  expect_error(invert_named(state.abb))
})

Try the campfin package in your browser

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

campfin documentation built on Oct. 20, 2023, 5:06 p.m.