Skip to content

Commit

Permalink
add regression tests for runif64 (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Dec 30, 2024
1 parent 1767136 commit 6ffb784
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test-hash64.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
test_that("runif64 behaves as expected", {
withr::local_seed(3478)

expect_identical(
runif64(10L),
as.integer64(c(
"6312937654860439830", "5047107428523623805", "7829389831893364707",
"-3641910282010306573", "4600438248413496767", "4871064969903669683",
"2693636032523872093", "4503042760826424596", "-8860474785465525016", "-4614238549190155011"
))
)

expect_identical(
runif64(5L, 10L, 20L),
as.integer64(c(16L, 19L, 16L, 15L, 20L))
)

# large enough number to be confident the test isn't "randomly" succeeding,
# but not so large as to noticeably slow down the suite.
x = runif64(100000L, -5L, 5L)
expect_true(all(x >= -5L & x <= 5L))
})

0 comments on commit 6ffb784

Please sign in to comment.