File: fuzz_csv.cpp

package info (click to toggle)
jsoncons 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 17,932 kB
  • sloc: cpp: 141,335; sh: 33; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>

#include <jsoncons_ext/csv/csv.hpp>

#include <jsoncons/json.hpp>
#include <jsoncons/json_reader.hpp>

using namespace jsoncons;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, std::size_t size)
{
        std::string input(reinterpret_cast<const char*>(data), size);
        json_decoder<ojson> decoder;
        auto options = csv::csv_options{}
            .assume_header(true)
            .mapping_kind(csv::csv_mapping_kind::n_rows);
        try {
                csv::csv_string_reader reader1(input, decoder, options);
                reader1.read();
        }
        catch (jsoncons::ser_error e) {}
        catch (jsoncons::json_runtime_error<std::runtime_error> e) {}
        catch (json_runtime_error<std::invalid_argument> e3) {}
        return 0;
}