#include "query.hpp" #include "trace.hpp" int main() { DECLARE( auto f = []( path, const json_value &v ) { return v.type() == json_type::integer ? v.int_value() : 0; } ); DECLARE( auto tt = []( path, const auto & ) { return true; } ); DECLARE( auto q = query( "[ 1, 2, 3 ]" ) ); DECLARE( auto mapped = q.map( f ) ); DECLARE( auto filtered = q.filter( tt ) ); DECLARE( auto mf = mapped.filter( tt ) ); DECLARE( auto fm = filtered.map( f ) ); DECLARE( auto i = mf.begin() ); DECLARE( auto j = fm.begin() ); for ( int count = 0; count < 4; ++ count ) { BIND( ( pi, ii ), *i ); BIND( ( pj, ij ), *j ); ASSERT( ( pi.empty() && pj.empty() ) || pi.front_i() == pj.front_i() ); ASSERT( ii == ij ); TRACE( ++i ); TRACE( ++j ); } }