Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prolem with std::random_device and generation of section names #1354

Open
osadowskyphd opened this issue Aug 7, 2018 · 0 comments
Open

Prolem with std::random_device and generation of section names #1354

osadowskyphd opened this issue Aug 7, 2018 · 0 comments

Comments

@osadowskyphd
Copy link

Description

I have a test that includes many randomized inputs. I wanted to trace them by including the randomization seed in a section name. The result is that the generated name completely misbehave if I use std::random_device to generate seeds, etc., while if I use pseudo-random generator things seem OK.

Steps to reproduce

TEST_CASE("Test random section name")
{
//std::random_device randomSource;
std::mt19937 randomSource(100);
std::uniform_int_distribution<size_t> generator;
std::vector<size_t> numbers;
for (size_t i = 0; i < 5; i++)
{
numbers.push_back(generator(randomSource));
}
for (size_t i = 0; i < 5; i++)
{
size_t number = numbers[i];
SECTION("Testing random number " + std::to_string(number))
{
std::cout << "Testing " << number << std::endl;
SUCCEED("Succeessful");
}
}
}
``

As written, this test succeeds with 5 pseudo-random numbers. However, replacing randomSource with a std::random_device makes an infinite loop.

There were multiple other issues when I used std::random_device, but this is the easiest to explain and the immediate need I have.

Extra information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant