File: test_alter.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 (57 lines) | stat: -rw-r--r-- 1,698 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
context("Test trie alteration")

testthat::test_that("String tries can be altered", {
  trie <- trie("foo", "bar")
  original_length <- length(trie)
  trie_add(trie, "baz", "qux")
  increased_length <- length(trie)
  trie_remove(trie, "baz")

  testthat::expect_true(original_length < increased_length)
  testthat::expect_true(length(trie) == original_length)
})

testthat::test_that("String tries can be altered", {
  trie <- trie("foo", "bar")
  original_length <- length(trie)
  trie_add(trie, "baz", "qux")
  increased_length <- length(trie)
  trie_remove(trie, "baz")

  testthat::expect_true(original_length < increased_length)
  testthat::expect_true(length(trie) == original_length)
})

testthat::test_that("Integer tries can be altered", {
  trie <- trie("foo", 1)
  original_length <- length(trie)
  trie_add(trie, "baz", 2)
  increased_length <- length(trie)
  trie_remove(trie, "baz")

  testthat::expect_true(original_length < increased_length)
  testthat::expect_true(length(trie) == original_length)
})


testthat::test_that("Numeric tries can be altered", {
  trie <- trie("foo", as.numeric(1))
  original_length <- length(trie)
  trie_add(trie, "baz", as.numeric(2))
  increased_length <- length(trie)
  trie_remove(trie, "baz")

  testthat::expect_true(original_length < increased_length)
  testthat::expect_true(length(trie) == original_length)
})

testthat::test_that("Logical tries can be altered", {
  trie <- trie("foo", FALSE)
  original_length <- length(trie)
  trie_add(trie, "baz", TRUE)
  increased_length <- length(trie)
  trie_remove(trie, "baz")

  testthat::expect_true(original_length < increased_length)
  testthat::expect_true(length(trie) == original_length)
})