valB = distB(rng);
- EXPECT_EQ(valA, valB);
+ EXPECT_REAL_EQ_TOL(valA, valB, gmx::test::ulpTolerance(0));
}
TEST(ExponentialDistributionTest, AltParam)
rngB.restart();
distA.reset();
distB.reset();
- EXPECT_EQ(distA(rngA), distB(rngB, paramA));
+ EXPECT_REAL_EQ_TOL(distA(rngA), distB(rngB, paramA), gmx::test::ulpTolerance(0));
}
} // namespace anonymous
valB = distB(rng);
- EXPECT_EQ(valA, valB);
+ EXPECT_REAL_EQ_TOL(valA, valB, gmx::test::ulpTolerance(0));
}
TEST(GammaDistributionTest, AltParam)
rngB.restart();
distA.reset();
distB.reset();
- EXPECT_EQ(distA(rngA), distB(rngB, paramA));
+ EXPECT_REAL_EQ_TOL(distA(rngA), distB(rngB, paramA), gmx::test::ulpTolerance(0));
}
} // namespace anonymous
gmx::ThreeFry2x64<8> rng(123456, gmx::RandomDomain::Other);
gmx::NormalDistribution<real> distA(2.0, 5.0);
gmx::NormalDistribution<real> distB(2.0, 5.0);
- gmx::NormalDistribution<>::result_type valA, valB;
+ gmx::NormalDistribution<real>::result_type valA, valB;
valA = distA(rng);
valB = distB(rng);
- EXPECT_EQ(valA, valB);
+ // Use floating-point test with no tolerance rather than
+ // exact test, since the latter leads to failures with
+ // 32-bit gcc-4.8.4
+ EXPECT_REAL_EQ_TOL(valA, valB, gmx::test::ulpTolerance(0));
}
TEST(NormalDistributionTest, AltParam)
gmx::NormalDistribution<real> distA(2.0, 5.0);
gmx::NormalDistribution<real> distB; // default parameters
gmx::NormalDistribution<real>::param_type paramA(2.0, 5.0);
+ gmx::NormalDistribution<real>::result_type valA, valB;
EXPECT_NE(distA(rngA), distB(rngB));
rngA.restart();
rngB.restart();
distA.reset();
distB.reset();
- EXPECT_EQ(distA(rngA), distB(rngB, paramA));
+
+ valA = distA(rngA);
+ valB = distB(rngB, paramA);
+
+ // Use floating-point test with no tolerance rather than
+ // exact test, since the latter leads to failures with
+ // 32-bit gcc-4.8.4
+ EXPECT_REAL_EQ_TOL(valA, valB, gmx::test::ulpTolerance(0));
}
} // namespace anonymous
valB = distB(rng);
- EXPECT_EQ(valA, valB);
+ EXPECT_REAL_EQ_TOL(valA, valB, gmx::test::ulpTolerance(0));
}
TEST(TabulatedNormalDistributionTest, AltParam)
rngB.restart();
distA.reset();
distB.reset();
- EXPECT_EQ(distA(rngA), distB(rngB, paramA));
+ EXPECT_REAL_EQ_TOL(distA(rngA), distB(rngB, paramA), gmx::test::ulpTolerance(0));
}
TEST(TabulatedNormalDistributionTableTest, HasValidProperties)
size_t halfSize = table.size() / 2;
double sumOfSquares = 0.0;
- auto tolerance = gmx::test::ulpTolerance(1);
+ // accept errors of a few ULP since the exact value of the summation
+ // below will depend on whether the compiler issues FMA instructions
+ auto tolerance = gmx::test::ulpTolerance(10);
for (size_t i = 0, iFromEnd = table.size()-1; i < halfSize; ++i, --iFromEnd)
{
EXPECT_REAL_EQ_TOL(table.at(i), -table.at(iFromEnd), tolerance)
TEST(UniformRealDistributionTest, Reset)
{
- gmx::ThreeFry2x64<8> rng(123456, gmx::RandomDomain::Other);
- gmx::UniformRealDistribution<real> distA(2.0, 5.0);
- gmx::UniformRealDistribution<real> distB(2.0, 5.0);
- gmx::UniformRealDistribution<>::result_type valA, valB;
+ gmx::ThreeFry2x64<8> rng(123456, gmx::RandomDomain::Other);
+ gmx::UniformRealDistribution<real> distA(2.0, 5.0);
+ gmx::UniformRealDistribution<real> distB(2.0, 5.0);
+ gmx::UniformRealDistribution<real>::result_type valA, valB;
valA = distA(rng);
valB = distB(rng);
- EXPECT_EQ(valA, valB);
+ // Use floating-point test with no tolerance rather than exact
+ // test, since the later fails with 32-bit gcc-4.8.4
+ EXPECT_REAL_EQ_TOL(valA, valB, gmx::test::ulpTolerance(0));
}
TEST(UniformRealDistributionTest, AltParam)
gmx::UniformRealDistribution<real> distA(2.0, 5.0);
gmx::UniformRealDistribution<real> distB; // default parameters
gmx::UniformRealDistribution<real>::param_type paramA(2.0, 5.0);
+ gmx::UniformRealDistribution<real>::result_type valA, valB;
EXPECT_NE(distA(rngA), distB(rngB));
rngA.restart();
rngB.restart();
distA.reset();
distB.reset();
- EXPECT_EQ(distA(rngA), distB(rngB, paramA));
+
+ valA = distA(rngA);
+ valB = distB(rngB, paramA);
+
+ // Use floating-point test with no tolerance rather than exact test,
+ // since the latter fails with 32-bit gcc-4.8.4
+ EXPECT_REAL_EQ_TOL(valA, valB, gmx::test::ulpTolerance(0));
}
} // namespace anonymous