File: test_convert.R

package info (click to toggle)
r-cran-triebeard 0.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 392 kB
  • sloc: cpp: 1,095; sh: 13; makefile: 2; ansic: 1
file content (21 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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")
})