Skip to content

Commit e33fc2d

Browse files
committed
add tests
1 parent db0b90b commit e33fc2d

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

RcppTskit/tests/testthat/test_TableCollection.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,14 @@ test_that("table_collection_sort wrapper validates inputs and sorts in place", {
310310
rtsk_table_collection_sort(tc_xptr, options = bitwShiftL(1L, 4)),
311311
regexp = "only supports options"
312312
)
313+
expect_error(
314+
rtsk_table_collection_sort(tc_xptr, options = -1L),
315+
regexp = "does not support negative options"
316+
)
317+
expect_error(
318+
rtsk_table_collection_sort(tc_xptr, site_start = 1L),
319+
regexp = "SORT_OFFSET_NOT_SUPPORTED|Sort offset"
320+
)
313321
expect_no_error(rtsk_table_collection_sort(tc_xptr))
314322
expect_no_error(rtsk_table_collection_sort(tc_xptr, 0L, 0L, 0L))
315323

RcppTskit/tests/testthat/test_misc.R

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ test_that("validate_options() branches are covered", {
5353
)
5454
})
5555

56+
test_that("R-side integer and row-index validators cover message branches", {
57+
# jarl-ignore internal_function: it's just a test
58+
expect_error(
59+
RcppTskit:::validate_integer_scalar_arg(1.5, "x"),
60+
regexp = "x must be a non-NA integer scalar!"
61+
)
62+
# jarl-ignore internal_function: it's just a test
63+
expect_error(
64+
RcppTskit:::validate_integer_scalar_arg(1L, "x", minimum = 2L),
65+
regexp = "x must be a non-NA integer scalar >= 2!"
66+
)
67+
# jarl-ignore internal_function: it's just a test
68+
expect_no_error(RcppTskit:::validate_row_index(NULL, allow_null = TRUE))
69+
})
70+
71+
test_that("TSK_NO_CHECK_INTEGRITY constant wrapper returns integer", {
72+
# jarl-ignore internal_function: it's just a test
73+
v <- RcppTskit:::rtsk_const_tsk_no_check_integrity()
74+
expect_true(is.integer(v))
75+
expect_equal(length(v), 1L)
76+
expect_true(v > 0L)
77+
})
78+
5679
test_that("rtsk_wrap_tsk_size_t_as_integer64() works", {
5780
# jarl-ignore internal_function: it's just a test
5881
x <- RcppTskit:::test_rtsk_wrap_tsk_size_t_as_integer64("0")

RcppTskit/tests/testthat/test_variant_iterator_low_level.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ test_that("low-level variant iterator validates bounds", {
7676
})
7777

7878
test_that("low-level variant iterator validates site-index range helper", {
79+
expect_no_error(test_variant_site_index_range("0", "0"))
80+
7981
expect_error(
8082
test_variant_site_index_range("2147483648", "0"),
8183
"Site index exceeds tsk_id_t range"

0 commit comments

Comments
 (0)