From 57b888ce0ebdeb34d866fd1511052fd740cc5ab8 Mon Sep 17 00:00:00 2001 From: Chandra Pratap Date: Fri, 5 Dec 2025 15:23:54 +0000 Subject: [PATCH] fuzz: Add a test case for `ParseByteUnits()` `ParseByteUnits()` is the only parsing function in `strencodings.cpp` lacking a fuzz test. Add a test case to check the function against arbitrary strings and randomized default_multiplier's. --- src/test/fuzz/string.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/fuzz/string.cpp b/src/test/fuzz/string.cpp index 443d7241b54..5d59eb34084 100644 --- a/src/test/fuzz/string.cpp +++ b/src/test/fuzz/string.cpp @@ -147,4 +147,19 @@ FUZZ_TARGET(string) const bilingual_str bs2{random_string_2, random_string_1}; (void)(bs1 + bs2); } + { + const ByteUnit all_units[] = { + ByteUnit::NOOP, + ByteUnit::k, + ByteUnit::K, + ByteUnit::m, + ByteUnit::M, + ByteUnit::g, + ByteUnit::G, + ByteUnit::t, + ByteUnit::T + }; + ByteUnit default_multiplier = fuzzed_data_provider.PickValueInArray(all_units); + (void)ParseByteUnits(random_string_1, default_multiplier); + } }