src/mongo/db/matcher/schema/expression_parser_schema_test.cpp
//
// Tests for parsing the $_internalSchemaMaxItems expression.
//
Tests for parsing the $_internalSchemaMaxItems expression.
Tests for parsing the $_internalSchemaMaxItems expression .
TEST(MatchExpressionParserInternalSchemaMaxItemsTest, CorrectlyParsesIntegerArgument) {
    BSONObj query = BSON("x" << BSON("$_internalSchemaMaxItems" << 2));
    const CollatorInterface* collator = nullptr;
    StatusWithMatchExpression result =
        MatchExpressionParser::parse(query, ExtensionsCallbackDisallowExtensions(), collator);
    ASSERT_TRUE(result.isOK());
    ASSERT(!result.getValue()->matchesBSON(BSON("x" << 1)));
    ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(1 << 2))));
    ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(1))));
    ASSERT(!result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(1 << 2 << 3))));
}
TEST ( MatchExpressionParserInternalSchemaMaxItemsTest , CorrectlyParsesIntegerArgument ) { BSONObj query = BSON ( " " << BSON ( " " << 2 ) ) ; const CollatorInterface * collator = nullptr ; StatusWithMatchExpression result = MatchExpressionParser :: parse ( query , ExtensionsCallbackDisallowExtensions ( ) , collator ) ; ASSERT_TRUE ( result . isOK ( ) ) ; ASSERT ( ! result . getValue ( ) -> matchesBSON ( BSON ( " " << 1 ) ) ) ; ASSERT ( result . getValue ( ) -> matchesBSON ( BSON ( " " << BSON_ARRAY ( 1 << 2 ) ) ) ) ; ASSERT ( result . getValue ( ) -> matchesBSON ( BSON ( " " << BSON_ARRAY ( 1 ) ) ) ) ; ASSERT ( ! result . getValue ( ) -> matchesBSON ( BSON ( " " << BSON_ARRAY ( 1 << 2 << 3 ) ) ) ) ; }
Tests for parsing the $_internalSchemaMaxItems expression.
Tests for parsing the $_internalSchemaMaxItems expression .