Skip to content

Commit b398229

Browse files
committed
test: add tests for multiple inputs in partitionsSample
Added tests to verify the behavior of `partitionsSample` and `partitionsRank` with multiple input types. Ensured that the output names and classes are as expected.
1 parent 9dd235a commit b398229

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/testthat/testPartitionsSampleRank.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,27 @@ test_that("parttionsSample and compositionsSample produces correct results", {
415415
nThreads = 2, target = 300)
416416
)
417417
)
418+
419+
## Multiple inputs
420+
mat_int = partitionsSample(
421+
1850, 3, TRUE, n = 10, seed = 1234, namedSample = TRUE
422+
)
423+
mat_dbl = partitionsSample(
424+
1850, 6, TRUE, n = 10, seed = 4321, namedSample = TRUE
425+
)
426+
mat_gmp = partitionsSample(
427+
1850, 15, TRUE, n = 10, seed = 9876, namedSample = TRUE
428+
)
429+
430+
myRank = partitionsRank(
431+
int = mat_int, dbl = mat_dbl, gmp = mat_gmp,
432+
v = 1850, repetition = TRUE
433+
)
434+
expect_named(myRank, c("int", "dbl", "gmp"))
435+
expect_equal(unname(sapply(myRank, class)), c("integer", "numeric", "bigz"))
436+
expect_true(all(mapply(function(x, y) {
437+
identical(as.character(x), rownames(y))
438+
}, myRank, list(mat_int, mat_dbl, mat_gmp))))
418439
})
419440

420441
test_that("compositionsCount produces correct results with multisets non weak case.", {

0 commit comments

Comments
 (0)