1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:47:34 +00:00

LibTest: Change #define-d constants into constexpr and a runtime flag

MAX_GENERATED_VALUES_PER_TEST is now the --randomized_runs flag:
$ ./Build/lagom/bin/TestGenerator --randomized_runs 1000

It's sometimes useful to try larger numbers for it instead of the
default of 100.

MAX_GEN_ATTEMPTS_PER_VALUE is now a constexpr. It's not usually needed
to tweak this value; we can recompile with a different value on the rare
occasion.
This commit is contained in:
Martin Janiczek 2023-10-27 11:47:43 +02:00 committed by Andrew Kaster
parent ed60a032a8
commit 4fc1daa69f
4 changed files with 23 additions and 18 deletions

View file

@ -7,11 +7,10 @@
#pragma once
#include <LibTest/Macros.h> // intentionally first -- we redefine VERIFY and friends in here
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/Vector.h>
#include <LibTest/Macros.h>
#include <LibTest/Randomized/RandomnessSource.h>
#include <LibTest/TestCase.h>
#include <LibTest/TestResult.h>
@ -61,6 +60,8 @@ public:
void enable_reporting() { m_reporting_enabled = true; }
void disable_reporting() { m_reporting_enabled = false; }
u64 randomized_runs() { return m_randomized_runs; }
private:
static TestSuite* s_global;
Vector<NonnullRefPtr<TestCase>> m_cases;
@ -68,6 +69,7 @@ private:
u64 m_benchtime = 0;
DeprecatedString m_suite_name;
u64 m_benchmark_repetitions = 1;
u64 m_randomized_runs = 100;
Function<void()> m_setup;
TestResult m_current_test_result = TestResult::NotRun;
Randomized::RandomnessSource m_randomness_source = Randomized::RandomnessSource::live();