Coverage Report

Created: 2026-01-09 06:11

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
5.90k
{
17
5.90k
    FuzzedDataProvider fdp{data, size};
18
5.90k
    try
19
5.90k
    {
20
5.90k
        const toml::table tbl = toml::parse(fdp.ConsumeRandomLengthString());
21
22
5.90k
        switch (fdp.ConsumeEnum<SerializationTest>())
23
5.90k
        {
24
16
            case SerializationTest::JSON:
25
16
                static_cast<void>(toml::json_formatter{tbl});
26
16
                break;
27
11
            case SerializationTest::YAML:
28
11
                static_cast<void>(toml::yaml_formatter{tbl});
29
11
                break;
30
12
            case SerializationTest::TOML:
31
12
                static_cast<void>(toml::toml_formatter{tbl});
32
3.28k
            default:
33
3.28k
                break;
34
5.90k
        }
35
5.90k
    }
36
5.90k
    catch (const toml::parse_error&)
37
5.90k
    {
38
2.59k
        return -1;
39
2.59k
    }
40
3.31k
    return 0;
41
5.90k
}