Commit graph

3 commits

Author SHA1 Message Date
Martin Janiczek
70ac6918d1 LibTest: Fix integer overflow in Gen::unsigned_int(u32)
NumericLimits<u32>::max + 1 overflowing to 0 caused us to call
AK::get_random_uniform(0) which doesn't make sense (the argument is an
_exclusive_ bound).
2023-11-18 10:01:29 +01:00
Martin Janiczek
4c068ba921 LibTest: Minimize footprint of Gen::unsigned_int, simplify code
unsigned_int(0) doesn't need to draw bits from RandomnessSource.

An expression for getting INT_MAX for u32 didn't need to be
special-cased over the general formula.

This is a follow-up on a few comments
2023-10-27 12:26:06 -06:00
Martin Janiczek
99e2d42a53 LibTest: Add a library of Generators
These functions all plug into RandomnessSource and produce random values
of various types. They are to be used either inside other generator
definitions or inside the GEN(...) macro when used in tests.
2023-10-26 17:26:52 -06:00