本文整理汇总了C++中NorMatchExpression类的典型用法代码示例。如果您正苦于以下问题:C++ NorMatchExpression类的具体用法?C++ NorMatchExpression怎么用?C++ NorMatchExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NorMatchExpression类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(NorOp, MatchesThreeClauses) {
BSONObj baseOperand1 = BSON("$gt" << 10);
BSONObj baseOperand2 = BSON("$lt" << 0);
BSONObj baseOperand3 = BSON("b" << 100);
unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression());
ASSERT(sub1->init("a", baseOperand1["$gt"]).isOK());
unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression());
ASSERT(sub2->init("a", baseOperand2["$lt"]).isOK());
unique_ptr<ComparisonMatchExpression> sub3(new EqualityMatchExpression());
ASSERT(sub3->init("b", baseOperand3["b"]).isOK());
NorMatchExpression norOp;
norOp.add(sub1.release());
norOp.add(sub2.release());
norOp.add(sub3.release());
ASSERT(!norOp.matchesBSON(BSON("a" << -1), NULL));
ASSERT(!norOp.matchesBSON(BSON("a" << 11), NULL));
ASSERT(norOp.matchesBSON(BSON("a" << 5), NULL));
ASSERT(!norOp.matchesBSON(BSON("b" << 100), NULL));
ASSERT(norOp.matchesBSON(BSON("b" << 101), NULL));
ASSERT(norOp.matchesBSON(BSONObj(), NULL));
ASSERT(!norOp.matchesBSON(BSON("a" << 11 << "b" << 100), NULL));
}
示例2: TEST
TEST( NorOp, MatchesSingleClause ) {
BSONObj baseOperand = BSON( "$ne" << 5 );
auto_ptr<ComparisonMatchExpression> ne( new ComparisonMatchExpression() );
ASSERT( ne->init( "a", ComparisonMatchExpression::NE, baseOperand[ "$ne" ] ).isOK() );
NorMatchExpression norOp;
norOp.add( ne.release() );
ASSERT( !norOp.matches( BSON( "a" << 4 ), NULL ) );
ASSERT( !norOp.matches( BSON( "a" << BSON_ARRAY( 4 << 6 ) ), NULL ) );
ASSERT( norOp.matches( BSON( "a" << 5 ), NULL ) );
ASSERT( norOp.matches( BSON( "a" << BSON_ARRAY( 4 << 5 ) ), NULL ) );
}