17Minisketch MakeFuzzMinisketch32(
size_t capacity, uint32_t impl)
19 return Assert(Minisketch(32, impl, capacity));
29 const uint32_t impl{fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, Minisketch::MaxImplementation())};
30 if (!Minisketch::ImplementationSupported(32, impl))
return;
32 Minisketch sketch_a{MakeFuzzMinisketch32(capacity, impl)};
33 Minisketch sketch_b{MakeFuzzMinisketch32(capacity, impl)};
34 sketch_a.SetSeed(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
35 sketch_b.SetSeed(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
38 std::map<uint32_t, bool> diff;
41 const auto entry{fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(1, std::numeric_limits<uint32_t>::max() - 1)};
42 const auto KeepDiff{[&] {
43 bool& mut{diff[entry]};
61 const auto num_diff{std::accumulate(diff.begin(), diff.end(),
size_t{0}, [](
auto n,
const auto& e) { return n + e.second; })};
63 Minisketch sketch_ar{MakeFuzzMinisketch32(capacity, impl)};
64 Minisketch sketch_br{MakeFuzzMinisketch32(capacity, impl)};
65 sketch_ar.SetSeed(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
66 sketch_br.SetSeed(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
68 sketch_ar.Deserialize(sketch_a.Serialize());
69 sketch_br.Deserialize(sketch_b.Serialize());
71 Minisketch sketch_diff{std::move(fuzzed_data_provider.ConsumeBool() ? sketch_a : sketch_ar)};
72 sketch_diff.Merge(fuzzed_data_provider.ConsumeBool() ? sketch_b : sketch_br);
74 if (capacity >= num_diff) {
75 const auto max_elements{fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(num_diff, capacity)};
76 const auto dec{*
Assert(sketch_diff.Decode(max_elements))};
77 Assert(dec.size() == num_diff);
#define Assert(val)
Identity function.
T ConsumeIntegralInRange(T min, T max)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
struct minisketch minisketch
Opaque type for decoded sketches.
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)