diff options
author | David Storch <david.storch@10gen.com> | 2016-08-12 15:58:56 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-08-18 11:14:17 -0400 |
commit | 26543060c852aac22f26143a04bf7789ec8fec53 (patch) | |
tree | df3ae49e5c4745058be29b7ec8a8e4b528b50a9a /src/mongo/db/fts | |
parent | 13fa28982d008568f7620d73ddec0c61fad7cbc8 (diff) | |
download | mongo-26543060c852aac22f26143a04bf7789ec8fec53.tar.gz |
SERVER-24508 BSONObj::ComparatorInterface
BSONObj instances should now be compared via the comparator
interface's evaluate() method. This preferred over using
BSONObj::woCompare() directly. If the comparison doesn't
require any database semantics (e.g. there is no collation),
there is a global instance of the SimpleBSONObjComparator
which should be used for BSONObj comparisons. If the
comparison requires special semantics, then callers must
instantiate their own comparator object.
Diffstat (limited to 'src/mongo/db/fts')
-rw-r--r-- | src/mongo/db/fts/fts_query_impl_test.cpp | 36 | ||||
-rw-r--r-- | src/mongo/db/fts/fts_spec_test.cpp | 22 |
2 files changed, 31 insertions, 27 deletions
diff --git a/src/mongo/db/fts/fts_query_impl_test.cpp b/src/mongo/db/fts/fts_query_impl_test.cpp index 43585e8a982..6cb8ca8f9de 100644 --- a/src/mongo/db/fts/fts_query_impl_test.cpp +++ b/src/mongo/db/fts/fts_query_impl_test.cpp @@ -158,9 +158,10 @@ TEST(FTSQueryImpl, Phrase1) { q.setDiacriticSensitive(false); ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK()); - ASSERT_EQUALS(q.toBSON(), - fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase " - "test'], negatedPhrases: []}")); + ASSERT_BSONOBJ_EQ( + q.toBSON(), + fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase " + "test'], negatedPhrases: []}")); ASSERT_TRUE(q.getTermsForBounds() == q.getPositiveTerms()); } @@ -182,7 +183,7 @@ TEST(FTSQueryImpl, HyphenDirectlyBeforePhraseShouldNegateEntirePhrase) { q.setCaseSensitive(false); q.setDiacriticSensitive(false); ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK()); - ASSERT_EQUALS( + ASSERT_BSONOBJ_EQ( q.toBSON(), fromjson( "{terms: ['fun'], negatedTerms: [], phrases: [], negatedPhrases: ['phrase test']}")); @@ -195,9 +196,10 @@ TEST(FTSQueryImpl, HyphenSurroundedByWhitespaceBeforePhraseShouldNotNegateEntire q.setCaseSensitive(false); q.setDiacriticSensitive(false); ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK()); - ASSERT_EQUALS(q.toBSON(), - fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase " - "test'], negatedPhrases: []}")); + ASSERT_BSONOBJ_EQ( + q.toBSON(), + fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase " + "test'], negatedPhrases: []}")); } TEST(FTSQueryImpl, HyphenBetweenTermAndPhraseShouldBeTreatedAsDelimiter) { @@ -207,9 +209,10 @@ TEST(FTSQueryImpl, HyphenBetweenTermAndPhraseShouldBeTreatedAsDelimiter) { q.setCaseSensitive(false); q.setDiacriticSensitive(false); ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK()); - ASSERT_EQUALS(q.toBSON(), - fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase " - "test'], negatedPhrases: []}")); + ASSERT_BSONOBJ_EQ( + q.toBSON(), + fromjson("{terms: ['fun', 'phrase', 'test'], negatedTerms: [], phrases: ['phrase " + "test'], negatedPhrases: []}")); } TEST(FTSQueryImpl, HyphenShouldNegateAllSucceedingPhrasesSeparatedByHyphens) { @@ -219,9 +222,9 @@ TEST(FTSQueryImpl, HyphenShouldNegateAllSucceedingPhrasesSeparatedByHyphens) { q.setCaseSensitive(false); q.setDiacriticSensitive(false); ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK()); - ASSERT_EQUALS(q.toBSON(), - fromjson("{terms: ['anoth', 'phrase'], negatedTerms: [], phrases: ['another " - "phrase'], negatedPhrases: ['really fun', 'stuff here']}")); + ASSERT_BSONOBJ_EQ(q.toBSON(), + fromjson("{terms: ['anoth', 'phrase'], negatedTerms: [], phrases: ['another " + "phrase'], negatedPhrases: ['really fun', 'stuff here']}")); } TEST(FTSQueryImpl, CaseSensitiveOption) { @@ -304,9 +307,10 @@ TEST(FTSQueryImpl, Mix1) { q.setCaseSensitive(false); q.setDiacriticSensitive(false); ASSERT(q.parse(TEXT_INDEX_VERSION_3).isOK()); - ASSERT_EQUALS(q.toBSON(), - fromjson("{terms: ['industri'], negatedTerms: ['melbourn', 'physic'], phrases: " - "['industry'], negatedPhrases: []}")); + ASSERT_BSONOBJ_EQ( + q.toBSON(), + fromjson("{terms: ['industri'], negatedTerms: ['melbourn', 'physic'], phrases: " + "['industry'], negatedPhrases: []}")); } TEST(FTSQueryImpl, NegPhrase2) { diff --git a/src/mongo/db/fts/fts_spec_test.cpp b/src/mongo/db/fts/fts_spec_test.cpp index 3c041cbd363..ca50a0d7511 100644 --- a/src/mongo/db/fts/fts_spec_test.cpp +++ b/src/mongo/db/fts/fts_spec_test.cpp @@ -54,7 +54,7 @@ void assertFixSuccess(const std::string& s) { // fixSpec() on an already-fixed spec shouldn't change it. BSONObj fixed2 = assertGet(FTSSpec::fixSpec(fixed)); - ASSERT_EQUALS(fixed, fixed2); + ASSERT_BSONOBJ_EQ(fixed, fixed2); } catch (UserException&) { ASSERT(false); } @@ -283,7 +283,7 @@ TEST(FTSSpec, Extra2) { ASSERT_EQUALS(StringData("x"), spec.extraAfter(0)); BSONObj fixed2 = assertGet(FTSSpec::fixSpec(fixed)); - ASSERT_EQUALS(fixed, fixed2); + ASSERT_BSONOBJ_EQ(fixed, fixed2); } TEST(FTSSpec, Extra3) { @@ -291,15 +291,15 @@ TEST(FTSSpec, Extra3) { << "text")); BSONObj fixed = assertGet(FTSSpec::fixSpec(user)); - ASSERT_EQUALS(BSON("x" << 1 << "_fts" - << "text" - << "_ftsx" - << 1), - fixed["key"].Obj()); - ASSERT_EQUALS(BSON("data" << 1), fixed["weights"].Obj()); + ASSERT_BSONOBJ_EQ(BSON("x" << 1 << "_fts" + << "text" + << "_ftsx" + << 1), + fixed["key"].Obj()); + ASSERT_BSONOBJ_EQ(BSON("data" << 1), fixed["weights"].Obj()); BSONObj fixed2 = assertGet(FTSSpec::fixSpec(fixed)); - ASSERT_EQUALS(fixed, fixed2); + ASSERT_BSONOBJ_EQ(fixed, fixed2); FTSSpec spec(fixed); ASSERT_EQUALS(1U, spec.numExtraBefore()); @@ -309,10 +309,10 @@ TEST(FTSSpec, Extra3) { BSONObj prefix; ASSERT(spec.getIndexPrefix(BSON("x" << 2), &prefix).isOK()); - ASSERT_EQUALS(BSON("x" << 2), prefix); + ASSERT_BSONOBJ_EQ(BSON("x" << 2), prefix); ASSERT(spec.getIndexPrefix(BSON("x" << 3 << "y" << 4), &prefix).isOK()); - ASSERT_EQUALS(BSON("x" << 3), prefix); + ASSERT_BSONOBJ_EQ(BSON("x" << 3), prefix); ASSERT(!spec.getIndexPrefix(BSON("x" << BSON("$gt" << 5)), &prefix).isOK()); ASSERT(!spec.getIndexPrefix(BSON("y" << 4), &prefix).isOK()); |