From 6ffb784e3420211ca8ba3e7f995ec1aee877a6c0 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 30 Dec 2024 11:26:28 +0800 Subject: [PATCH] add regression tests for runif64 (#126) --- tests/testthat/test-hash64.R | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/testthat/test-hash64.R diff --git a/tests/testthat/test-hash64.R b/tests/testthat/test-hash64.R new file mode 100644 index 0000000..3627629 --- /dev/null +++ b/tests/testthat/test-hash64.R @@ -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)) +})