1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 09:58:14 +00:00

LibTest: Add more numeric generators

Rename unsigned_int generator to number_u32.
Add generators:
- number_u64
- number_f64
- percentage
This commit is contained in:
Martin Janiczek 2023-12-30 16:23:59 +01:00 committed by Andrew Kaster
parent dd53f64d2f
commit d52ffcd830
15 changed files with 312 additions and 133 deletions

View file

@ -26,11 +26,11 @@ public:
static RandomnessSource live() { return RandomnessSource(RandomRun(), true); }
static RandomnessSource recorded(RandomRun const& run) { return RandomnessSource(run, false); }
RandomRun& run() { return m_run; }
u32 draw_value(u32 max, Function<u32()> random_generator)
u64 draw_value(u64 max, Function<u64()> random_generator)
{
// Live: use the random generator and remember the value.
if (m_is_live) {
u32 value = random_generator();
u64 value = random_generator();
m_run.append(value);
return value;
}