Skip to content

Commit

Permalink
add test for RNGState constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyjmurray committed Sep 28, 2024
1 parent 42dcb2e commit c5ad4af
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/test_basic_rng/test_r123.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<RNG>();
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<RNG> 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:
Expand Down

0 comments on commit c5ad4af

Please sign in to comment.