#include "jsongen.hpp" void damaged( std::string &s, int idx, char c ) { std::swap( s[ idx ], c ); if ( s.size() < 200 ) EXCEPT( json_error, json_parse( s ), "s =", s ); else EXCEPT( json_error, json_parse( s ), "s → long invalid input, size =", s.size() ); std::swap( s[ idx ], c ); } int main() { std::mt19937 rand( 0 ); for ( int i = 0; i < 2000; ++i ) { gen_t gen( i ); gen.max_size = 60; gen.max_depth = 4; gen.max_length = 10; gen.value(); CLEAR(); for ( char c : { '{', '}', '[', ']', ':' } ) { int idx = gen.rand() % gen.str.size(); if ( gen.str[ idx ] != c ) damaged( gen.str, idx, c ); } } gen_t gen( 0 ); gen.max_size = vg_select( 256 * 1024, 1024 ); gen.max_depth = 500; gen.max_length = 1000; gen.value(); for ( char c : { 'x', ':', ',', '[', ']', '{', '}', '0', '1' } ) { if ( c != '{' ) damaged( gen.str, gen.str.rfind( '{' ), c ); if ( c != '[' ) damaged( gen.str, gen.str.rfind( '[' ), c ); if ( c != ':' ) damaged( gen.str, gen.str.rfind( ':' ), c ); if ( c != ',' ) damaged( gen.str, gen.str.rfind( ',' ), c ); } }