Skip to content

Commit

Permalink
STYLE: Add using-declaration MersenneTwisterRandomVariateGenerator GTest
Browse files Browse the repository at this point in the history
No longer specified the namespace `itk::Statistics` in each of its unit tests.
  • Loading branch information
N-Dekker authored and dzenanz committed Oct 6, 2023
1 parent 89d4735 commit bdcb9e3
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <gtest/gtest.h>
#include <random> // For mt19937.

// The class to be tested.
using itk::Statistics::MersenneTwisterRandomVariateGenerator;


// Tests that GetIntegerVariate() conforms with the C++11 requirement for std::mt19937,
// when the ITK generator uses the default seed of std::mt19937:
Expand All @@ -29,7 +32,7 @@
// (C++11 section "Engines and engine adaptors with predefined parameters", [rand.predef])
TEST(MersenneTwisterRandomVariateGenerator, GetIntegerVariateConformsWithStdMt19937Requirement)
{
const auto generator = itk::Statistics::MersenneTwisterRandomVariateGenerator::New();
const auto generator = MersenneTwisterRandomVariateGenerator::New();
generator->SetSeed(std::mt19937::default_seed);

for (int i = 1; i < 10000; ++i)
Expand All @@ -50,7 +53,7 @@ TEST(MersenneTwisterRandomVariateGenerator, GetIntegerVariateConformsWithStdMt19
// as std::mt19937, when std::mt19937 uses the same seed as the ITK generator.
TEST(MersenneTwisterRandomVariateGenerator, GetIntegerVariateReturnsSameAsStdMt19937)
{
const auto generator = itk::Statistics::MersenneTwisterRandomVariateGenerator::New();
const auto generator = MersenneTwisterRandomVariateGenerator::New();
std::mt19937 stdMt19937{ generator->GetSeed() };

// Just repeat a few times, assuming that that should be enough.
Expand All @@ -63,14 +66,12 @@ TEST(MersenneTwisterRandomVariateGenerator, GetIntegerVariateReturnsSameAsStdMt1

TEST(MersenneTwisterRandomVariateGenerator, ResetNextSeed)
{
using GeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;

const auto globalGenerator = GeneratorType::GetInstance();
const auto globalGenerator = MersenneTwisterRandomVariateGenerator::GetInstance();
ASSERT_NE(globalGenerator, nullptr);

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

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

0 comments on commit bdcb9e3

Please sign in to comment.