Coverage Report

Created: 2025-10-13 06:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tomlplusplus/fuzzing/toml_fuzzer.cpp
Line
Count
Source
1
#include <cstdint>
2
#include <fuzzer/FuzzedDataProvider.h>
3
4
#include <toml++/toml.hpp>
5
6
enum class SerializationTest
7
{
8
    NONE = 0,
9
    JSON,
10
    YAML,
11
    TOML,
12
    kMaxValue = TOML
13
};
14
15
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, const std::size_t size)
16
6.78k
{
17
6.78k
    FuzzedDataProvider fdp{data, size};
18
6.78k
    try
19
6.78k
    {
20
6.78k
        const toml::table tbl = toml::parse(fdp.ConsumeRandomLengthString());
21
22
6.78k
        switch (fdp.ConsumeEnum<SerializationTest>())
23
6.78k
        {
24
16
            case SerializationTest::JSON:
25
16
                static_cast<void>(toml::json_formatter{tbl});
26
16
                break;
27
16
            case SerializationTest::YAML:
28
16
                static_cast<void>(toml::yaml_formatter{tbl});
29
16
                break;
30
5
            case SerializationTest::TOML:
31
5
                static_cast<void>(toml::toml_formatter{tbl});
32
3.67k
            default:
33
3.67k
                break;
34
6.78k
        }
35
6.78k
    }
36
6.78k
    catch (const toml::parse_error&)
37
6.78k
    {
38
3.08k
        return -1;
39
3.08k
    }
40
3.70k
    return 0;
41
6.78k
}