json/test/fuzz.cpp

35 lines
751 B
C++
Raw Normal View History

/*
__ _____ _____ _____
__| | __| | | | JSON for Modern C++ (fuzz test support)
| | |__ | | | | | | version 2.0.0
|_____|_____|_____|_|___| https://github.com/nlohmann/json
2016-02-15 01:38:29 +08:00
Run "make fuzz_testing" and follow the instructions.
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
*/
#include <json.hpp>
using json = nlohmann::json;
int main()
{
#ifdef __AFL_HAVE_MANUAL_CONTROL
2016-02-15 01:38:29 +08:00
while (__AFL_LOOP(1000))
{
#endif
2016-02-15 01:38:29 +08:00
try
{
json j(std::cin);
2016-02-15 04:36:56 +08:00
std::cout << j << std::endl;
2016-02-15 01:38:29 +08:00
}
2016-02-15 05:24:45 +08:00
catch (std::invalid_argument& e)
2016-02-15 01:38:29 +08:00
{
std::cout << "Invalid argument in parsing" << e.what() << '\n';
}
#ifdef __AFL_HAVE_MANUAL_CONTROL
2016-02-15 01:38:29 +08:00
}
#endif
}