Line data Source code
1 : /** 2 : * Unit tests for the Number Theory modules PRNGs 3 : */ 4 : #include <gtest/gtest.h> 5 : #include <iostream> 6 : #include <openGPMP/nt/random.hpp> 7 : 8 4 : TEST(LCGTest, DefaultConstructor) { 9 1 : gpmp::core::rndm::LCG generator; 10 : 11 : // Generate a few random numbers and ensure they are within bounds 12 11 : for (int i = 0; i < 10; ++i) { 13 10 : uint64_t result = generator(); 14 10 : EXPECT_GE(result, 0); 15 10 : EXPECT_LE(result, std::numeric_limits<uint64_t>::max()); 16 : } 17 1 : } 18 : 19 4 : TEST(LCGTest, CustomConstructor) { 20 1 : uint64_t seed = 123; 21 1 : uint64_t a = 6364136223846793005ULL; 22 1 : uint64_t c = 1442695040888963407ULL; 23 : 24 1 : gpmp::core::rndm::LCG generator(seed, a, c); 25 : 26 : // Generate a few random numbers and ensure they are within bounds 27 11 : for (int i = 0; i < 10; ++i) { 28 10 : uint64_t result = generator(); 29 10 : EXPECT_GE(result, 0); 30 10 : EXPECT_LE(result, std::numeric_limits<uint64_t>::max()); 31 : } 32 1 : }