Skip to content

Commit

Permalink
extendr-macro: wrote tests for #[extendr] enum
Browse files Browse the repository at this point in the history
conversions
  • Loading branch information
CGMossa committed Feb 18, 2024
1 parent 247cb4b commit b7e8eca
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/extendrtests/tests/testthat/test-enum-conversion.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
test_that("non-factor integer vector", {
expect_error(
tst_enum_wrapper(NULL, c(1L))
)
expect_error(
tst_enum_wrapper(NULL, 1L)
)
})
test_that("non-scalar factor vector", {
expect_error(
tst_enum_wrapper(NULL, factor(c("A", "B"), levels = c("A", "B", "C")))
)
})
test_that("invalid levels", {
expect_error(
tst_enum_wrapper(NULL, factor(c("B"), levels = c("a", "b", "c")))
)
})
test_that("scalar conversion test", {
expect_equal(
my_enum("B"),
factor(c("B"), levels = c("A", "B", "C"))
)
})

0 comments on commit b7e8eca

Please sign in to comment.