File: test_arrays.R

package info (click to toggle)
r-cran-rcpptoml 0.2.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 280 kB
  • sloc: cpp: 204; sh: 14; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,118 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

library(RcppTOML)

toml <- parseToml("arrays.toml")

expect_equal(names(toml), c("array", "fruit", "products"))
expect_equal(names(toml$array), paste0("key", 1:6))

expect_equal(toml$array$key1, 1:3)
expect_equal(class(toml$array$key1), "integer")

expect_equal(toml$array$key2, c("red", "yellow", "green"))

expect_equal(toml$array$key3[[1]], 1:2)
expect_equal(toml$array$key3[[2]], 3:5)

expect_equal(toml$array$key4[[1]], 1:2)
expect_equal(toml$array$key4[[2]], letters[1:3])

expect_equal(toml$array$key5, 1:3)

expect_equal(toml$array$key6, 1:2)

expect_equal(toml$fruit[[1]]$name, "apple")
expect_equal(toml$fruit[[1]]$physical, list(color="red", shape="round"))
expect_equal(toml$fruit[[1]]$variety, list(list(name="red delicious"),
                                           list(name="granny smith")))
expect_equal(toml$fruit[[2]]$name, "banana")
expect_equal(toml$fruit[[2]]$variety, list(list(name="plantain")))

expect_equal(toml$products[[1]], list(name="Hammer", sku=738594937L))
expect_equal(toml$products[[2]], list())
expect_equal(toml$products[[3]], list(color="gray", name="Nail", sku=284758393L))