tests/testthat/test_convert.R

testthat::context("Test conversion of tries into other R objects")

testthat::test_that("Tries can be turned into lists", {
  trie_inst <- trie("foo", "bar")
  trlist <- as.list(trie_inst)
  testthat::expect_true(is.list(trlist))
  testthat::expect_equal(length(trlist), 2)
  testthat::expect_equal(names(trlist), c("keys", "values"))
  testthat::expect_equal(trlist$values, "bar")
  testthat::expect_equal(trlist$keys, "foo")
})

testthat::test_that("Tries can be turned into lists", {
  trie_inst <- trie("foo", "bar")
  trlist <- as.data.frame(trie_inst)
  testthat::expect_true(is.data.frame(trlist))
  testthat::expect_equal(ncol(trlist), 2)
  testthat::expect_equal(names(trlist), c("keys", "values"))
  testthat::expect_equal(trlist$values, "bar")
  testthat::expect_equal(trlist$keys, "foo")
})

Try the triebeard package in your browser

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

triebeard documentation built on March 7, 2023, 6:55 p.m.