本文整理汇总了C++中OrMatchExpression::matches方法的典型用法代码示例。如果您正苦于以下问题:C++ OrMatchExpression::matches方法的具体用法?C++ OrMatchExpression::matches怎么用?C++ OrMatchExpression::matches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrMatchExpression
的用法示例。
在下文中一共展示了OrMatchExpression::matches方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
/*
TEST( OrOp, MatchesElementThreeClauses ) {
BSONObj baseOperand1 = BSON( "$lt" << 0 );
BSONObj baseOperand2 = BSON( "$gt" << 10 );
BSONObj baseOperand3 = BSON( "a" << 5 );
BSONObj match1 = BSON( "a" << -1 );
BSONObj match2 = BSON( "a" << 11 );
BSONObj match3 = BSON( "a" << 5 );
BSONObj notMatch = BSON( "a" << "6" );
auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() );
ASSERT( sub1->init( "a", baseOperand1[ "$lt" ] ).isOK() );
auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() );
ASSERT( sub2->init( "a", baseOperand2[ "$gt" ] ).isOK() );
auto_ptr<ComparisonMatchExpression> sub3( new ComparisonMatchExpression() );
ASSERT( sub3->init( "a", baseOperand3[ "a" ] ).isOK() );
OwnedPointerVector<MatchMatchExpression> subMatchExpressions;
subMatchExpressions.mutableVector().push_back( sub1.release() );
subMatchExpressions.mutableVector().push_back( sub2.release() );
subMatchExpressions.mutableVector().push_back( sub3.release() );
OrOp orOp;
ASSERT( orOp.init( &subMatchExpressions ).isOK() );
ASSERT( orOp.matchesSingleElement( match1[ "a" ] ) );
ASSERT( orOp.matchesSingleElement( match2[ "a" ] ) );
ASSERT( orOp.matchesSingleElement( match3[ "a" ] ) );
ASSERT( !orOp.matchesSingleElement( notMatch[ "a" ] ) );
}
*/
TEST( OrOp, MatchesSingleClause ) {
BSONObj baseOperand = BSON( "$ne" << 5 );
auto_ptr<ComparisonMatchExpression> ne( new ComparisonMatchExpression() );
ASSERT( ne->init( "a", ComparisonMatchExpression::NE, baseOperand[ "$ne" ] ).isOK() );
OrMatchExpression orOp;
orOp.add( ne.release() );
ASSERT( orOp.matches( BSON( "a" << 4 ), NULL ) );
ASSERT( orOp.matches( BSON( "a" << BSON_ARRAY( 4 << 6 ) ), NULL ) );
ASSERT( !orOp.matches( BSON( "a" << 5 ), NULL ) );
ASSERT( !orOp.matches( BSON( "a" << BSON_ARRAY( 4 << 5 ) ), NULL ) );
}