Skip to content
Snippets Groups Projects
Commit ac6ff1e7 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Check whether all items are chosen at least once

parent 897bf426
No related branches found
No related tags found
No related merge requests found
......@@ -52,11 +52,17 @@ BOOST_AUTO_TEST_CASE(test_choice)
{
std::vector<std::string> items { "a", "b", "c" };
for (int i = 0; i < 100; ++i)
std::set<std::string> allChosen;
for (int i = 0; i < 1e5; ++i)
{
std::string chosen = simox::random::choice(items);
BOOST_CHECK(std::find(items.begin(), items.end(), chosen) != items.end());
allChosen.insert(chosen);
}
// All items must be hit at least once ... very likely.
BOOST_CHECK_EQUAL(allChosen.size(), 3);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment