Skip to content

Commit

Permalink
Add new test to UNIT_Rand_TEST and modify 876_regression_test
Browse files Browse the repository at this point in the history
  • Loading branch information
scpeters committed Oct 22, 2013
1 parent 9b2fb37 commit 6ff5ea4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions gazebo/math/Rand_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,24 @@ TEST(RandTest, Rand)
EXPECT_TRUE(math::equal(d, 0.985827));
}
}

TEST(RandTest, SetSeed)
{
int N = 10;
std::vector<int> first;
std::vector<int> second;

for (int i = 0; i < N; ++i)
{
math::Rand::SetSeed(i);
first.push_back(math::Rand::GetIntUniform(-10, 10));
second.push_back(math::Rand::GetIntUniform(-10, 10));
}

for (int i = 0; i < N; ++i)
{
math::Rand::SetSeed(i);
EXPECT_EQ(first[i], math::Rand::GetIntUniform(-10, 10));
EXPECT_EQ(second[i], math::Rand::GetIntUniform(-10, 10));
}
}
2 changes: 2 additions & 0 deletions test/regression/876_random_number_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ TEST_F(Issue876Test, Reset)
physics::WorldPtr world = physics::get_world("default");
ASSERT_TRUE(world);

math::Rand::SetSeed(math::Rand::GetSeed());

int sampleCount = 500;

std::vector<int> num;
Expand Down

0 comments on commit 6ff5ea4

Please sign in to comment.