-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtest_gather_spread.R
55 lines (41 loc) · 1.06 KB
/
test_gather_spread.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
context("test_gather")
test_that("gather", {
expect_message({
outlog <- tidylog::gather(mtcars)
})
expect_equal(nrow(outlog), 352)
expect_equal(ncol(outlog), 2)
expect_silent({
outtidy <- tidyr::gather(mtcars)
})
expect_equal(outlog, outtidy)
})
test_that("gather: argument order", {
expect_message({
out_ab <- tidylog::gather(.data = mtcars, carb)
})
expect_message({
out_ba <- tidylog::gather(carb, .data = mtcars)
})
expect_equal(out_ab, out_ba)
})
test_that("spread", {
expect_message({
outlog <- tidylog::spread(mtcars, hp, carb)
})
expect_equal(nrow(outlog), 32)
expect_equal(ncol(outlog), 31)
expect_silent({
outtidyr <- tidyr::spread(mtcars, hp, carb)
})
expect_equal(outlog, outtidyr)
})
test_that("spread: argument order", {
expect_message({
out_ab <- tidylog::spread(.data = mtcars, hp, carb)
})
expect_message({
out_ba <- tidylog::spread(hp, carb, .data = mtcars)
})
expect_equal(out_ab, out_ba)
})