From c5ad4af29671ae2959076854a7485d9582ad1923 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Sat, 28 Sep 2024 12:53:13 -0400 Subject: [PATCH] add test for RNGState constructors --- test/test_basic_rng/test_r123.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/test_basic_rng/test_r123.cc b/test/test_basic_rng/test_r123.cc index b63a4ab..0f35766 100644 --- a/test/test_basic_rng/test_r123.cc +++ b/test/test_basic_rng/test_r123.cc @@ -672,6 +672,37 @@ void run_ut_uniform(){ // MARK: my tests + Googletest +class TestRNGState : public ::testing::Test { + + protected: + + void test_uint_key_constructors() { + using RNG = r123::Philox4x32; + // No-arugment constructor + auto s = RandBLAS::RNGState(); + ASSERT_EQ(s.len_k, 2); + ASSERT_EQ(s.key[0], 0); + ASSERT_EQ(s.key[1], 0); + for (int i = 0; i < 4; ++i) { + ASSERT_EQ(s.counter[i], 0) << "Failed at index " << i; + } + // unsigned-int constructor + RandBLAS::RNGState t(42); + ASSERT_EQ(t.len_k, 2); + ASSERT_EQ(t.key[0], 42); + ASSERT_EQ(t.key[1], 0); + for (int i = 0; i < 4; ++i) { + ASSERT_EQ(t.counter[i], 0) << "Failed at index " << i; + } + return; + } +}; + +TEST_F(TestRNGState, uint_key_constructors) { + test_uint_key_constructors(); +} + + class TestRandom123 : public ::testing::Test { protected: