mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
00934bc344
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.
35 lines
848 B
C++
35 lines
848 B
C++
/*
|
|
* Copyright (c) 2023, Martin Janiczek <martin@janiczek.cz>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
namespace Test {
|
|
|
|
// TestResult signals to the TestSuite how the TestCase execution went.
|
|
enum class TestResult {
|
|
NotRun,
|
|
|
|
// Test fn ran to completion without setting any of the below flags
|
|
Passed,
|
|
|
|
// Didn't get through EXPECT(...).
|
|
Failed,
|
|
|
|
// Didn't get through the ASSUME(...) filter 15 times in a row
|
|
// (in a randomized test).
|
|
// Alternatively, user used REJECT(...).
|
|
Rejected,
|
|
|
|
// Ran out of RandomRun data (in a randomized test, when shrinking).
|
|
// This is fine, we'll just try some other shrink.
|
|
Overrun,
|
|
};
|
|
|
|
// Used eg. to signal we've ran out of prerecorded random bits.
|
|
// Defined in TestSuite.cpp
|
|
void set_current_test_result(TestResult);
|
|
|
|
} // namespace Test
|