You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 astd::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
The text was updated successfully, but these errors were encountered: