mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibTest: Add the REJECT and ASSUME macros
REJECT and ASSUME are useful for filtering out unwanted generated values. While this is not ideal, it is ocassionally useful and so we include it for convenience. The main loop of RANDOMIZED_TEST_CASE runs the test case 100 times, each time trying to generate a different set of values. Inside that loop, if it sees a REJECT (ASSUME is implemented in terms of REJECT), it retries up to 15 times before giving up (perhaps it's impossible or just very improbable to generate a value that will survive REJECT or ASSUME). REJECT("Reason for rejecting") will just outright fail, while ASSUME(bool) is more of an equivalent of a .filter() method from functional languages.
This commit is contained in:
parent
1bcfead020
commit
00934bc344
3 changed files with 26 additions and 0 deletions
|
@ -103,6 +103,8 @@ static DeprecatedString test_result_to_string(TestResult result)
|
|||
return "Completed";
|
||||
case TestResult::Failed:
|
||||
return "Failed";
|
||||
case TestResult::Rejected:
|
||||
return "Rejected";
|
||||
case TestResult::Overrun:
|
||||
return "Ran out of randomness";
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue