Skip to content

Commit

Permalink
measure type.convert=TRUE tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Dylan Hocking committed Dec 18, 2024
1 parent a5a089d commit 4a29589
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/testthat/test-CRAN-measure.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ test_engines("measure single value", {
expect_identical(out, expected)
})

test_engines("measure single value type.convert=TRUE", {
out <- melt(DT, measure.vars=nc::measure(
letter="[ab]", "_", number="[12]", type.convert=TRUE))
expected <- data.table(
letter=c("a","b","a"),
number=as.integer(c(1,2,2)),
value=c(10,21,20))
expect_identical(out, expected)
})

test_engines("measure multiple values", {
out <- melt(DT, measure.vars=nc::measure(
column="[ab]", "_", number="[12]", as.integer))
Expand All @@ -25,3 +35,12 @@ test_engines("measure multiple values", {
expect_identical(out, expected)
})

test_engines("measure multiple values type.convert=TRUE", {
out <- melt(DT, measure.vars=nc::measure(
column="[ab]", "_", number="[12]", type.convert=TRUE))
expected <- data.table(
number=as.integer(c(1,2)),
a=c(10,20),
b=c(NA,21))
expect_identical(out, expected)
})

0 comments on commit 4a29589

Please sign in to comment.