Skip to content

Commit

Permalink
capture_melt_single, capture_melt_multiple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Dylan Hocking committed Dec 18, 2024
1 parent 4a29589 commit 781137c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Changes in version 2024.12.17

- capture_first_vec, capture_all_str, capture_first_df now support type.convert argument. TRUE means to use utils::type.convert(x,as.is=TRUE) as default conversion function (as.is=TRUE means to return character instead of factor), FALSE means identity, and otherwise can be any function to use as default conversion.
- capture_first_vec, capture_all_str, capture_first_df, capture_first_glob, measure, capture_melt_single, capture_melt_multiple now support type.convert argument. TRUE means to use utils::type.convert(x,as.is=TRUE) as default conversion function (as.is=TRUE means to return character instead of factor), FALSE means identity, and otherwise can be any function to use as default conversion.

Changes in version 2024.9.20

Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-CRAN-melt.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ test_engines("melting lots of columns is OK", {
expect_identical(out$value, i.vec)
})

test_engines("melting lots of columns type.convert=TRUE is OK", {
out <- capture_melt_single(one.row, "X", col="[0-9]+", type.convert=TRUE)
expect_identical(out$col, i.vec)
expect_identical(out$value, i.vec)
})

DT.wide <- data.table(id=0, num_ref=1, name_ref="foo", num=2, name="bar")
test_engines("converting NA to non-NA is an error", {
expect_error({
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-CRAN-multiple.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ test_engines("multiple melting lots of columns is OK", {
expect_identical(out$C, c.vec)
})

test_engines("multiple melting lots of columns type.convert=TRUE is OK", {
out <- capture_melt_multiple(
one.row, column=".", "[.]", int="[0-9]+", type.convert=TRUE)
expect_identical(out$int, i.vec)
expect_identical(out$I, i.vec)
expect_identical(out$C, c.vec)
})

wide.metrics <- data.table(
FP.possible=8202, FN.possible=1835,
FP.count=0, FN.count=1835)
Expand Down

0 comments on commit 781137c

Please sign in to comment.