Commit 4a49deb7 authored by Isaak Lim's avatar Isaak Lim
Browse files

- fixed the RandomNumberGenerator, where it numbers greater than 1.0 could be returned

- activated the corresponding unit tests

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@727 fdac6126-5c0c-442c-9429-916003d36597
parent 849ee4d2
......@@ -66,7 +66,7 @@ namespace OpenMesh {
RandomNumberGenerator::RandomNumberGenerator(const double _resolution) :
resolution_(_resolution),
iterations_(1),
maxNum_(RAND_MAX)
maxNum_(RAND_MAX + 1.0)
{
double tmp = resolution_;
while (tmp > (double(RAND_MAX) + 1.0) ) {
......
......@@ -53,8 +53,8 @@ TEST_F(RandomNumberGenerator, RandomNumberGeneratorMaxTestHighres) {
average /= 100000000.0;
// EXPECT_EQ(0u, lowerZero ) << "Below zero!";
// EXPECT_EQ(0u, above1 ) << "Above zero!";
EXPECT_EQ(0u, lowerZero ) << "Below zero!";
EXPECT_EQ(0u, above1 ) << "Above zero!";
EXPECT_TRUE( (average - 0.5) < 0.01 ) << "Expected value not 0.5";
}
......@@ -76,8 +76,6 @@ TEST_F(RandomNumberGenerator, RandomNumberGeneratorMaxTestLowres) {
if ( randomNumber > 1.0 ) {
above1++;
std::cerr << "randomNumber " << randomNumber << std::endl;
std::cerr << "resolution " << rng.resolution() << std::endl;
}
average += randomNumber;
......@@ -85,8 +83,8 @@ TEST_F(RandomNumberGenerator, RandomNumberGeneratorMaxTestLowres) {
average /= 10000000.0;
// EXPECT_EQ(0u, lowerZero ) << "Below zero!";
// EXPECT_EQ(0u, above1 ) << "Above zero!";
EXPECT_EQ(0u, lowerZero ) << "Below zero!";
EXPECT_EQ(0u, above1 ) << "Above zero!";
EXPECT_TRUE( (average - 0.5) < 0.01 ) << "Expected value not 0.5";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment