File: test_get.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 (29 lines) | stat: -rw-r--r-- 1,031 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
22
23
24
25
26
27
28
29
context("Test key and value retrieval")

testthat::test_that("String keys and values can be retrieved", {
  string_trie <- trie(LETTERS, LETTERS)
  testthat::expect_equal(LETTERS, get_values(string_trie))
  testthat::expect_equal(LETTERS, get_keys(string_trie))
})

testthat::test_that("Integer keys and values can be retrieved", {
  int_trie <- trie(LETTERS, 1:length(LETTERS))
  testthat::expect_equal(1:length(LETTERS), get_values(int_trie))
  testthat::expect_equal(LETTERS, get_keys(int_trie))
})

testthat::test_that("Numeric keys and values can be retrieved", {
  vals <- as.double(1:length(LETTERS))
  double_trie <- trie(LETTERS, vals)

  testthat::expect_equal(vals, get_values(double_trie))
  testthat::expect_equal(LETTERS, get_keys(double_trie))
})

testthat::test_that("Boolean keys and values can be retrieved", {
  vals <- as.logical(rep(c(0,1), (length(LETTERS)/2)))
  bool_trie <- trie(LETTERS, vals)

  testthat::expect_equal(vals, get_values(bool_trie))
  testthat::expect_equal(LETTERS, get_keys(bool_trie))
})