Coverage Report

Created: 2026-10-28 06:37

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