#include "trace.hpp" #include "parser.hpp" int main() { std::string t = "{x:0,y:0,z:{x:0},u:[10,-1],v:[{}],w:[1]}"; for ( int q = 0; q < int( t.size() ); ++ q ) for ( int p = 0; p < q; ++ p ) { CLEAR(); std::string s = t.substr( 0, p ) + ( p % 2 ? " " : "\t" ) + t.substr( p, q - p ) + ( p % 2 ? "\n" : " " ) + t.substr( q, t.npos ); std::string s_esc = s; while ( s_esc.find( '\n' ) != s_esc.npos ) s_esc.replace( s_esc.find( '\n' ), 1, "\\n" ); if ( s.find( "{}" ) == s.npos ) continue; if ( s.find( "-1" ) == s.npos || s.find( "10" ) == s.npos ) { EXCEPT( json_error, json_parse( s ), "s =", s_esc ); continue; } DECLARE( auto top = json_parse( s ), "s =", s_esc ); ASSERT( top->type() == json_type::object ); ASSERT( top->length() ); int i = 0; for ( auto t : { json_type::array, json_type::array, json_type::array, json_type::integer, json_type::integer, json_type::object } ) ASSERT( top->item_at( i++ ).type() == t, "i =", i, "t =", int( t ) ); i = 0; for ( auto l : { 2, 1, 1, 0, 0, 1 } ) ASSERT( top->item_at( i++ ).length() == l, "i =", i ); } }