diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-12-28 21:58:00 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-01-02 15:07:07 +0100 |
commit | fa9949b91414ee0da376a322cee32ba4e3989d8c (patch) | |
tree | 10cf748ce8c83c85d6a8f6fc490c42754055fe83 /src/test/fuzz/util.h | |
parent | faaef9434c19e3643322ee442c240c166af5adbd (diff) |
fuzz: Add ConsumeWeakEnum helper, Extract ALL_NET_PERMISSION_FLAGS
Diffstat (limited to 'src/test/fuzz/util.h')
-rw-r--r-- | src/test/fuzz/util.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index cd5da8aae8..1aa6463b88 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -87,6 +87,14 @@ template <typename T> return obj; } +template <typename WeakEnumType, size_t size> +[[nodiscard]] WeakEnumType ConsumeWeakEnum(FuzzedDataProvider& fuzzed_data_provider, const WeakEnumType (&all_types)[size]) noexcept +{ + return fuzzed_data_provider.ConsumeBool() ? + fuzzed_data_provider.PickValueInArray<WeakEnumType>(all_types) : + WeakEnumType(fuzzed_data_provider.ConsumeIntegral<typename std::underlying_type<WeakEnumType>::type>()); +} + [[nodiscard]] inline opcodetype ConsumeOpcodeType(FuzzedDataProvider& fuzzed_data_provider) noexcept { return static_cast<opcodetype>(fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, MAX_OPCODE)); |