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-14 18:38:29 +01: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-14 18:38:29 +01:00
while (__AFL_LOOP(1000))
{
#endif
2016-02-14 18:38:29 +01:00
try
{
json j(std::cin);
2016-02-14 21:36:56 +01:00
std::cout << j << std::endl;
2016-02-14 18:38:29 +01:00
}
2016-02-14 22:24:45 +01:00
catch (std::invalid_argument& e)
2016-02-14 18:38:29 +01:00
{
std::cout << "Invalid argument in parsing" << e.what() << '\n';
}
#ifdef __AFL_HAVE_MANUAL_CONTROL
2016-02-14 18:38:29 +01:00
}
#endif
}