本文整理汇总了C++中AndMatchExpression::matchesBSON方法的典型用法代码示例。如果您正苦于以下问题:C++ AndMatchExpression::matchesBSON方法的具体用法?C++ AndMatchExpression::matchesBSON怎么用?C++ AndMatchExpression::matchesBSON使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AndMatchExpression
的用法示例。
在下文中一共展示了AndMatchExpression::matchesBSON方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BSON
TEST(AndOp, ElemMatchKey) {
BSONObj baseOperand1 = BSON("a" << 1);
BSONObj baseOperand2 = BSON("b" << 2);
unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression());
ASSERT(sub1->init("a", baseOperand1["a"]).isOK());
unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression());
ASSERT(sub2->init("b", baseOperand2["b"]).isOK());
AndMatchExpression andOp;
andOp.add(sub1.release());
andOp.add(sub2.release());
MatchDetails details;
details.requestElemMatchKey();
ASSERT(!andOp.matchesBSON(BSON("a" << BSON_ARRAY(1)), &details));
ASSERT(!details.hasElemMatchKey());
ASSERT(!andOp.matchesBSON(BSON("b" << BSON_ARRAY(2)), &details));
ASSERT(!details.hasElemMatchKey());
ASSERT(andOp.matchesBSON(BSON("a" << BSON_ARRAY(1) << "b" << BSON_ARRAY(1 << 2)), &details));
ASSERT(details.hasElemMatchKey());
// The elem match key for the second $and clause is recorded.
ASSERT_EQUALS("1", details.elemMatchKey());
}
示例2: ASSERT
TEST(AndOp, NoClauses) {
AndMatchExpression andMatchExpression;
ASSERT(andMatchExpression.matchesBSON(BSONObj(), NULL));
}