File: test-performance.R

package info (click to toggle)
r-cran-ggplot2 3.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,748 kB
  • sloc: sh: 15; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 828 bytes parent folder | download | duplicates (2)
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
# modify_list() -----------------------------------------------------------

testlist <- list(
  a = 5.5,
  b = "x",
  c = 1:10
)
testappend <- list(
  b = "y",
  c = NULL,
  d = FALSE
)

test_that("modifyList is masked", {
  expect_error(modifyList(testlist, testappend))
})

test_that("modify_list retains unreferenced elements", {
  res <- modify_list(testlist, testappend)
  expect_equal(testlist$a, res$a)
})
test_that("modify_list overwrites existing values", {
  res <- modify_list(testlist, testappend)
  expect_equal(res$b, testappend$b)
})
test_that("modify_list adds new values", {
  res <- modify_list(testlist, testappend)
  expect_equal(res$d, testappend$d)
})
test_that("modify_list erases null elements", {
  res <- modify_list(testlist, testappend)
  expect_null(res$c)
  expect_named(res, c('a', 'b', 'd'))
})