Coverage Report

Created: 2025-11-15 06:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/glaze/fuzzing/json_reflection.cpp
Line
Count
Source
1
#include <array>
2
#include <cstddef>
3
#include <cstdint>
4
#include <glaze/glaze.hpp>
5
#include <vector>
6
7
struct my_struct
8
{
9
   int i = 287;
10
   double d = 3.14;
11
   std::string hello = "Hello World";
12
   std::array<uint64_t, 3> arr = {1, 2, 3};
13
};
14
15
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size)
16
11.3k
{
17
   // use a vector with null termination instead of a std::string to avoid
18
   // small string optimization to hide bounds problems
19
11.3k
   std::vector<char> buffer{Data, Data + Size};
20
21
   // non-null terminated
22
11.3k
   {
23
11.3k
      my_struct obj{};
24
11.3k
      [[maybe_unused]] auto ec =
25
11.3k
         glz::read<glz::opts{.null_terminated = false}>(obj, std::string_view{buffer.data(), Size});
26
11.3k
   }
27
28
   // null terminated
29
11.3k
   {
30
11.3k
      buffer.push_back('\0');
31
11.3k
      [[maybe_unused]] auto s = glz::read_json<my_struct>(std::string_view{buffer.data(), Size});
32
11.3k
      if (s) {
33
         // hooray! valid json found
34
5
      }
35
11.3k
   }
36
37
11.3k
   return 0;
38
11.3k
}