1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:57:34 +00:00

LibTest: Add the RandomnessSource abstraction

This will be a foundational part of bootstrapping generators: this is
the way they'll get prerecorded values from / record random values into
RandomRuns. (Generators don't get in contact with RandomRuns
themselves, they just interact with the RandomnessSource.)
This commit is contained in:
Martin Janiczek 2023-10-24 00:35:15 +02:00 committed by Andrew Kaster
parent d4e4189a34
commit 7e5a3650fe
5 changed files with 91 additions and 0 deletions

View file

@ -52,6 +52,18 @@ void set_current_test_result(TestResult result)
TestSuite::the().set_current_test_result(result);
}
// Declared in Macros.h
void set_randomness_source(Randomized::RandomnessSource source)
{
TestSuite::the().set_randomness_source(move(source));
}
// Declared in Macros.h
Randomized::RandomnessSource& randomness_source()
{
return TestSuite::the().randomness_source();
}
// Declared in TestCase.h
void add_test_case_to_suite(NonnullRefPtr<TestCase> const& test_case)
{
@ -73,6 +85,8 @@ static DeprecatedString test_result_to_string(TestResult result)
return "Completed";
case TestResult::Failed:
return "Failed";
case TestResult::Overrun:
return "Ran out of randomness";
default:
return "Unknown TestResult";
}