Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: ResetNextSeed GTest should not use instance for GetNextSeed call #4290

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ TEST(MersenneTwisterRandomVariateGenerator, GetIntegerVariateReturnsSameAsStdMt1
}


// Tests that two GetNextSeed() calls return the very same seed value, when ResetNextSeed() is called before each of
// those calls.
TEST(MersenneTwisterRandomVariateGenerator, ResetNextSeed)
{
const auto globalGenerator = MersenneTwisterRandomVariateGenerator::GetInstance();
ASSERT_NE(globalGenerator, nullptr);
// Call GetInstance() beforehand, to make sure the global instance is there already when calling GetNextSeed().
[[maybe_unused]] const auto globalGenerator = MersenneTwisterRandomVariateGenerator::GetInstance();

MersenneTwisterRandomVariateGenerator::ResetNextSeed();
const auto nextSeed = globalGenerator->GetNextSeed();
const auto seed = MersenneTwisterRandomVariateGenerator::GetNextSeed();

MersenneTwisterRandomVariateGenerator::ResetNextSeed();
EXPECT_EQ(globalGenerator->GetNextSeed(), nextSeed);
EXPECT_EQ(MersenneTwisterRandomVariateGenerator::GetNextSeed(), seed);
}