diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-02-15 11:47:54 -0500 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-02-16 09:33:13 -0500 |
commit | 89d37b751cb9404a81a33f4effc5c4657a17b359 (patch) | |
tree | 5338cfaf4993157f4bb0fcd5cf6c416c758b114a /src/mongo/db/matcher/expression_array_test.cpp | |
parent | 38c0eb538d0fd390c6cb9ce9ae9894153f6e8ef5 (diff) | |
download | mongo-89d37b751cb9404a81a33f4effc5c4657a17b359.tar.gz |
SERVER-28017 ne should respect the collection default collation
Diffstat (limited to 'src/mongo/db/matcher/expression_array_test.cpp')
-rw-r--r-- | src/mongo/db/matcher/expression_array_test.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/expression_array_test.cpp b/src/mongo/db/matcher/expression_array_test.cpp index 201d11fbed4..6a7f36cebed 100644 --- a/src/mongo/db/matcher/expression_array_test.cpp +++ b/src/mongo/db/matcher/expression_array_test.cpp @@ -35,6 +35,7 @@ #include "mongo/db/matcher/expression.h" #include "mongo/db/matcher/expression_array.h" #include "mongo/db/matcher/expression_tree.h" +#include "mongo/db/query/collation/collator_interface_mock.h" namespace mongo { @@ -153,6 +154,23 @@ TEST(ElemMatchObjectMatchExpression, ElemMatchKey) { ASSERT_EQUALS("2", details.elemMatchKey()); } +TEST(ElemMatchObjectMatchExpression, Collation) { + BSONObj baseOperand = BSON("b" + << "string"); + BSONObj match = BSON("a" << BSON_ARRAY(BSON("b" + << "string"))); + BSONObj notMatch = BSON("a" << BSON_ARRAY(BSON("b" + << "string2"))); + unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression()); + ASSERT(eq->init("b", baseOperand["b"]).isOK()); + ElemMatchObjectMatchExpression op; + ASSERT(op.init("a", eq.release()).isOK()); + CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kAlwaysEqual); + op.setCollator(&collator); + ASSERT(op.matchesSingleElement(match["a"])); + ASSERT(op.matchesSingleElement(notMatch["a"])); +} + /** TEST( ElemMatchObjectMatchExpression, MatchesIndexKey ) { BSONObj baseOperand = BSON( "b" << 5 ); |