Exemplo n.º 1
0
 TEST( NotMatchExpression, MatchesScalar ) {
     BSONObj baseOperand = BSON( "$lt" << 5 );
     auto_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() );
     ASSERT( lt->init( "a", ComparisonMatchExpression::LT, baseOperand[ "$lt" ] ).isOK() );
     NotMatchExpression notOp;
     ASSERT( notOp.init( lt.release() ).isOK() );
     ASSERT( notOp.matches( BSON( "a" << 6 ), NULL ) );
     ASSERT( !notOp.matches( BSON( "a" << 4 ), NULL ) );
 }
Exemplo n.º 2
0
 TEST( NotMatchExpression, MatchesArray ) {
     BSONObj baseOperand = BSON( "$lt" << 5 );
     auto_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() );
     ASSERT( lt->init( "a", ComparisonMatchExpression::LT, baseOperand[ "$lt" ] ).isOK() );
     NotMatchExpression notOp;
     ASSERT( notOp.init( lt.release() ).isOK() );
     ASSERT( notOp.matches( BSON( "a" << BSON_ARRAY( 6 ) ), NULL ) );
     ASSERT( !notOp.matches( BSON( "a" << BSON_ARRAY( 4 ) ), NULL ) );
     // All array elements must match.
     ASSERT( !notOp.matches( BSON( "a" << BSON_ARRAY( 4 << 5 << 6 ) ), NULL ) );
 }
Exemplo n.º 3
0
 TEST( NotMatchExpression, ElemMatchKey ) {
     BSONObj baseOperand = BSON( "$lt" << 5 );
     auto_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() );
     ASSERT( lt->init( "a", ComparisonMatchExpression::LT, baseOperand[ "$lt" ] ).isOK() );
     NotMatchExpression notOp;
     ASSERT( notOp.init( lt.release() ).isOK() );
     MatchDetails details;
     details.requestElemMatchKey();
     ASSERT( !notOp.matches( BSON( "a" << BSON_ARRAY( 1 ) ), &details ) );
     ASSERT( !details.hasElemMatchKey() );
     ASSERT( notOp.matches( BSON( "a" << 6 ), &details ) );
     ASSERT( !details.hasElemMatchKey() );
     ASSERT( notOp.matches( BSON( "a" << BSON_ARRAY( 6 ) ), &details ) );
     // elemMatchKey is not implemented for negative match operators.
     ASSERT( !details.hasElemMatchKey() );
 }