mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +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:
parent
dd53f64d2f
commit
d52ffcd830
15 changed files with 312 additions and 133 deletions
|
@ -122,10 +122,10 @@ TEST_CASE(unsigned_to_signed_regression)
|
|||
|
||||
RANDOMIZED_TEST_CASE(finds_number_that_is_present)
|
||||
{
|
||||
GEN(vec, Gen::vector(1, 16, []() { return Gen::unsigned_int(); }));
|
||||
GEN(i, Gen::unsigned_int(0, vec.size() - 1));
|
||||
GEN(vec, Gen::vector(1, 16, []() { return Gen::number_u64(); }));
|
||||
GEN(i, Gen::number_u64(0, vec.size() - 1));
|
||||
AK::quick_sort(vec);
|
||||
u32 n = vec[i];
|
||||
u64 n = vec[i];
|
||||
auto ptr = binary_search(vec, n);
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
EXPECT_EQ(*ptr, n);
|
||||
|
@ -133,10 +133,10 @@ RANDOMIZED_TEST_CASE(finds_number_that_is_present)
|
|||
|
||||
RANDOMIZED_TEST_CASE(doesnt_find_number_that_is_not_present)
|
||||
{
|
||||
GEN(vec, Gen::vector(1, 16, []() { return Gen::unsigned_int(); }));
|
||||
GEN(vec, Gen::vector(1, 16, []() { return Gen::number_u64(); }));
|
||||
AK::quick_sort(vec);
|
||||
|
||||
u32 not_present = 0;
|
||||
u64 not_present = 0;
|
||||
while (!vec.find(not_present).is_end()) {
|
||||
++not_present;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue