-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-names.R
32 lines (20 loc) · 1.04 KB
/
test-names.R
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
context("Checking names")
test_that("names are changed by assigment",{
minimal <- structure("abc", class = c("regexr", "character"), regex = list(
"a", "b", structure("c", class = c("regex", "character"),
comment = "A love note to your future self")), comments = list(
NULL, NULL, "A love note to your future self"))
names(minimal)[2:3] <- c("Foo", "Bar")
x <- c("", "Foo", "Bar")
expect_equivalent(names(minimal), x)
})
test_that("names are changed by setting (similar to `setNames`)",{
minimal <- structure("abc", class = c("regexr", "character"), regex = list(
"a", "b", "c"), comments = list(NULL, NULL, NULL))
out <- set_names(minimal, 1:3)
out_check <- structure("abc", class = c("regexr", "character"), regex = structure(list(
`1` = "a", `2` = "b", `3` = "c"), .Names = c("1", "2", "3"
)), comments = structure(list(`1` = NULL, `2` = NULL, `3` = NULL), .Names = c("1",
"2", "3")))
expect_equivalent(out, out_check)
})