Skip to content

Commit

Permalink
Add tests [revdep skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinCCYap committed Jan 20, 2022
1 parent 60d48c4 commit 3e08ab9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/testthat/test-mergingandstackingutilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ test_that("allIdentical", {
expect_equal(allIdentical(x = c(1, 1, 1)), TRUE)
})

test_that("allValueAttributesIdentical", {
val.attr <- structure(1:3, .Names = c("A", "B", "C"))
expect_equal(allValueAttributesIdentical(list(val.attr, rev(val.attr))), TRUE)
expect_equal(allValueAttributesIdentical(list(val.attr, rev(val.attr)[1:2])), FALSE)
})

test_that("removeNA", {
expect_equal(removeNA(x = c(NA, 1, 2, NA, 3)), c(1, 2 ,3))
})
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-stacking.R
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,17 @@ test_that("stackingSpecifiedByVariable", {
"ignored as it contains variables with mismatching ",
"types or value attributes."))
expect_equal(stacking.groups, structure(6:8, .Dim = c(1L, 3L)))

# Value attributes in different order
v.val.attr.3 <- v.val.attr
v.val.attr.3[[2]] <- rev(v.val.attr.3[[2]])
expect_warning(stacking.groups <- stackingSpecifiedByVariable(c("Q2_A-Q2_D", "Q3_*"),
list(variable.names = v.names,
variable.types = v.types,
variable.value.attributes = v.val.attr.3)), NA)
expect_equal(stacking.groups,
structure(c(2L, 6L, 3L, 7L, 4L, 8L, 5L, NA),
.Dim = c(2L, 4L)))
})

test_that("stackingSpecifiedByObservation", {
Expand Down

0 comments on commit 3e08ab9

Please sign in to comment.