summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2016-08-12 15:58:56 -0400
committerDavid Storch <david.storch@10gen.com>2016-08-18 11:14:17 -0400
commit26543060c852aac22f26143a04bf7789ec8fec53 (patch)
treedf3ae49e5c4745058be29b7ec8a8e4b528b50a9a /src/mongo/dbtests
parent13fa28982d008568f7620d73ddec0c61fad7cbc8 (diff)
downloadmongo-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/dbtests')
-rw-r--r--src/mongo/dbtests/chunktests.cpp2
-rw-r--r--src/mongo/dbtests/dbhelper_tests.cpp2
-rw-r--r--src/mongo/dbtests/extensions_callback_real_test.cpp4
-rw-r--r--src/mongo/dbtests/index_access_method_test.cpp8
-rw-r--r--src/mongo/dbtests/indexupdatetests.cpp6
-rw-r--r--src/mongo/dbtests/jsobjtests.cpp50
-rw-r--r--src/mongo/dbtests/jstests.cpp6
-rw-r--r--src/mongo/dbtests/mock/mock_replica_set.cpp4
-rw-r--r--src/mongo/dbtests/query_stage_delete.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_ensure_sorted.cpp2
-rw-r--r--src/mongo/dbtests/query_stage_ixscan.cpp20
-rw-r--r--src/mongo/dbtests/query_stage_merge_sort.cpp6
-rw-r--r--src/mongo/dbtests/query_stage_subplan.cpp6
-rw-r--r--src/mongo/dbtests/query_stage_update.cpp10
-rw-r--r--src/mongo/dbtests/querytests.cpp12
-rw-r--r--src/mongo/dbtests/repltests.cpp2
-rw-r--r--src/mongo/dbtests/rollbacktests.cpp2
-rw-r--r--src/mongo/dbtests/sort_key_generator_test.cpp34
-rw-r--r--src/mongo/dbtests/updatetests.cpp165
19 files changed, 174 insertions, 169 deletions
diff --git a/src/mongo/dbtests/chunktests.cpp b/src/mongo/dbtests/chunktests.cpp
index cadf44ae4f0..86a95684387 100644
--- a/src/mongo/dbtests/chunktests.cpp
+++ b/src/mongo/dbtests/chunktests.cpp
@@ -94,7 +94,7 @@ public:
for (const ShardId& shardId : shardIds) {
b << shardId;
}
- ASSERT_EQUALS(expectedShardNames(), b.arr());
+ ASSERT_BSONOBJ_EQ(expectedShardNames(), b.arr());
}
protected:
diff --git a/src/mongo/dbtests/dbhelper_tests.cpp b/src/mongo/dbtests/dbhelper_tests.cpp
index aee6a0f406a..f7027bb8f91 100644
--- a/src/mongo/dbtests/dbhelper_tests.cpp
+++ b/src/mongo/dbtests/dbhelper_tests.cpp
@@ -78,7 +78,7 @@ public:
}
// Check that the expected documents remain.
- ASSERT_EQUALS(expected(), docs(&txn));
+ ASSERT_BSONOBJ_EQ(expected(), docs(&txn));
}
private:
diff --git a/src/mongo/dbtests/extensions_callback_real_test.cpp b/src/mongo/dbtests/extensions_callback_real_test.cpp
index abe62080fbe..60b1c662f79 100644
--- a/src/mongo/dbtests/extensions_callback_real_test.cpp
+++ b/src/mongo/dbtests/extensions_callback_real_test.cpp
@@ -256,7 +256,7 @@ TEST_F(ExtensionsCallbackRealTest, WhereExpressionsWithSameScopeHaveSameBSONRepr
BSONObjBuilder builder2;
expr2->serialize(&builder2);
- ASSERT_EQ(builder1.obj(), builder2.obj());
+ ASSERT_BSONOBJ_EQ(builder1.obj(), builder2.obj());
}
TEST_F(ExtensionsCallbackRealTest,
@@ -275,7 +275,7 @@ TEST_F(ExtensionsCallbackRealTest,
BSONObjBuilder builder2;
expr2->serialize(&builder2);
- ASSERT_NE(builder1.obj(), builder2.obj());
+ ASSERT_BSONOBJ_NE(builder1.obj(), builder2.obj());
}
TEST_F(ExtensionsCallbackRealTest, WhereExpressionsWithSameScopeAreEquivalent) {
diff --git a/src/mongo/dbtests/index_access_method_test.cpp b/src/mongo/dbtests/index_access_method_test.cpp
index 5460ce410f0..59c769d6e87 100644
--- a/src/mongo/dbtests/index_access_method_test.cpp
+++ b/src/mongo/dbtests/index_access_method_test.cpp
@@ -194,14 +194,14 @@ TEST(IndexAccessMethodSetDifference, ShouldNotReportOverlapsFromNonDisjointSets)
for (auto&& obj : diff.first) {
ASSERT(left.find(obj) != left.end());
// Make sure it's not in the intersection.
- ASSERT(obj != BSON("" << 1));
- ASSERT(obj != BSON("" << 4));
+ ASSERT_BSONOBJ_NE(obj, BSON("" << 1));
+ ASSERT_BSONOBJ_NE(obj, BSON("" << 4));
}
for (auto&& obj : diff.second) {
ASSERT(right.find(obj) != right.end());
// Make sure it's not in the intersection.
- ASSERT(obj != BSON("" << 1));
- ASSERT(obj != BSON("" << 4));
+ ASSERT_BSONOBJ_NE(obj, BSON("" << 1));
+ ASSERT_BSONOBJ_NE(obj, BSON("" << 4));
}
}
diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp
index 99f254cb60d..6b9ee3e23ae 100644
--- a/src/mongo/dbtests/indexupdatetests.cpp
+++ b/src/mongo/dbtests/indexupdatetests.cpp
@@ -967,11 +967,11 @@ protected:
class IndexCatatalogFixIndexKey {
public:
void run() {
- ASSERT_EQUALS(BSON("x" << 1), IndexCatalog::fixIndexKey(BSON("x" << 1)));
+ ASSERT_BSONOBJ_EQ(BSON("x" << 1), IndexCatalog::fixIndexKey(BSON("x" << 1)));
- ASSERT_EQUALS(BSON("_id" << 1), IndexCatalog::fixIndexKey(BSON("_id" << 1)));
+ ASSERT_BSONOBJ_EQ(BSON("_id" << 1), IndexCatalog::fixIndexKey(BSON("_id" << 1)));
- ASSERT_EQUALS(BSON("_id" << 1), IndexCatalog::fixIndexKey(BSON("_id" << true)));
+ ASSERT_BSONOBJ_EQ(BSON("_id" << 1), IndexCatalog::fixIndexKey(BSON("_id" << true)));
}
};
diff --git a/src/mongo/dbtests/jsobjtests.cpp b/src/mongo/dbtests/jsobjtests.cpp
index f9583ea7b36..d2182b557fd 100644
--- a/src/mongo/dbtests/jsobjtests.cpp
+++ b/src/mongo/dbtests/jsobjtests.cpp
@@ -569,7 +569,7 @@ public:
ASSERT(tmp.valid());
ASSERT(tmp.hasField("a"));
ASSERT(!tmp.hasField("b"));
- ASSERT(tmp == BSON("a" << 1));
+ ASSERT_BSONOBJ_EQ(tmp, BSON("a" << 1));
bb << "b" << 2;
BSONObj obj = bb.obj();
@@ -577,7 +577,7 @@ public:
ASSERT(obj.valid());
ASSERT(obj.hasField("a"));
ASSERT(obj.hasField("b"));
- ASSERT(obj == BSON("a" << 1 << "b" << 2));
+ ASSERT_BSONOBJ_EQ(obj, BSON("a" << 1 << "b" << 2));
}
{
BSONObjBuilder bb;
@@ -587,7 +587,7 @@ public:
ASSERT(tmp.valid());
ASSERT(tmp.hasField("a"));
ASSERT(!tmp.hasField("b"));
- ASSERT(tmp == BSON("a" << BSON("$gt" << 1)));
+ ASSERT_BSONOBJ_EQ(tmp, BSON("a" << BSON("$gt" << 1)));
bb << "b" << LT << 2;
BSONObj obj = bb.obj();
@@ -596,7 +596,7 @@ public:
ASSERT(obj.valid());
ASSERT(obj.hasField("a"));
ASSERT(obj.hasField("b"));
- ASSERT(obj == BSON("a" << BSON("$gt" << 1) << "b" << BSON("$lt" << 2)));
+ ASSERT_BSONOBJ_EQ(obj, BSON("a" << BSON("$gt" << 1) << "b" << BSON("$lt" << 2)));
}
{
BSONObjBuilder bb(32);
@@ -606,7 +606,7 @@ public:
ASSERT(tmp.valid());
ASSERT(tmp.hasField("a"));
ASSERT(!tmp.hasField("b"));
- ASSERT(tmp == BSON("a" << 1));
+ ASSERT_BSONOBJ_EQ(tmp, BSON("a" << 1));
// force a realloc
BSONArrayBuilder arr;
@@ -939,11 +939,11 @@ public:
BSONObj C = c.obj();
// test that nulls are ok within bson strings
- ASSERT(!(A == B));
- ASSERT(A > B);
+ ASSERT_BSONOBJ_NE(A, B);
+ ASSERT_BSONOBJ_GT(A, B);
- ASSERT(!(B == C));
- ASSERT(C > B);
+ ASSERT_BSONOBJ_NE(B, C);
+ ASSERT_BSONOBJ_GT(C, B);
// check iteration is ok
ASSERT(B["z"].Bool() && A["z"].Bool() && C["z"].Bool());
@@ -979,7 +979,7 @@ public:
BSONObj foo = BSON("foo" << 1);
b.appendAs(foo.firstElement(), "bar");
}
- ASSERT_EQUALS(BSON("bar" << 1), b.done());
+ ASSERT_BSONOBJ_EQ(BSON("bar" << 1), b.done());
}
};
@@ -1388,8 +1388,8 @@ public:
ASSERT_EQUALS(oid.asDateT(), now);
ASSERT_EQUALS(min.asDateT(), now);
ASSERT_EQUALS(max.asDateT(), now);
- ASSERT_LT(BSON("" << min), BSON("" << oid));
- ASSERT_GT(BSON("" << max), BSON("" << oid));
+ ASSERT_BSONOBJ_LT(BSON("" << min), BSON("" << oid));
+ ASSERT_BSONOBJ_GT(BSON("" << max), BSON("" << oid));
}
};
@@ -1853,8 +1853,8 @@ public:
struct NestedDottedConversions {
void t(const BSONObj& nest, const BSONObj& dot) {
- ASSERT_EQUALS(nested2dotted(nest), dot);
- ASSERT_EQUALS(nest, dotted2nested(dot));
+ ASSERT_BSONOBJ_EQ(nested2dotted(nest), dot);
+ ASSERT_BSONOBJ_EQ(nest, dotted2nested(dot));
}
void run() {
@@ -1927,7 +1927,7 @@ struct BSONArrayBuilderTest {
BSONObj obj = objb.obj();
BSONArray arr = arrb.arr();
- ASSERT_EQUALS(obj, arr);
+ ASSERT_BSONOBJ_EQ(obj, arr);
BSONObj o = BSON("obj" << obj << "arr" << arr << "arr2" << BSONArray(obj) << "regex"
<< BSONRegEx("reg", "x"));
@@ -1954,7 +1954,7 @@ struct ArrayMacroTest {
<< "baz"
<< "qux")));
- ASSERT_EQUALS(arr, obj);
+ ASSERT_BSONOBJ_EQ(arr, obj);
ASSERT_EQUALS(arr["2"].type(), Object);
ASSERT_EQUALS(arr["2"].embeddedObject()["foo"].type(), Array);
}
@@ -2141,7 +2141,7 @@ public:
char* crap = (char*)mongoMalloc(x.objsize());
memcpy(crap, x.objdata(), x.objsize());
BSONObj y(crap);
- ASSERT_EQUALS(x, y);
+ ASSERT_BSONOBJ_EQ(x, y);
free(crap);
}
@@ -2218,7 +2218,7 @@ public:
BSONObj y = BSON("a" << BSON("b" << 1.0));
keyTest(x);
keyTest(y);
- ASSERT_EQUALS(x, y);
+ ASSERT_BSONOBJ_EQ(x, y);
ASSERT_EQUALS(0, x.woCompare(y));
}
};
@@ -2249,7 +2249,7 @@ public:
ASSERT_EQUALS(3, i.next().numberInt());
ASSERT(!i.more());
- ASSERT_EQUALS(BSON("x" << 1 << "y" << 2 << "z" << 3), b.obj());
+ ASSERT_BSONOBJ_EQ(BSON("x" << 1 << "y" << 2 << "z" << 3), b.obj());
}
}
};
@@ -2279,13 +2279,13 @@ public:
BSONObj e = BSON("a" << 4);
BSONObj f = BSON("a" << 4);
- ASSERT(!(a < b));
- ASSERT(a <= b);
- ASSERT(a < c);
+ ASSERT(!SimpleBSONObjComparator::kInstance.evaluate((a < b)));
+ ASSERT(SimpleBSONObjComparator::kInstance.evaluate(a <= b));
+ ASSERT(SimpleBSONObjComparator::kInstance.evaluate(a < c));
- ASSERT(f > d);
- ASSERT(f >= e);
- ASSERT(!(f > e));
+ ASSERT(SimpleBSONObjComparator::kInstance.evaluate(f > d));
+ ASSERT(SimpleBSONObjComparator::kInstance.evaluate(f >= e));
+ ASSERT(!(SimpleBSONObjComparator::kInstance.evaluate(f > e)));
}
};
diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp
index 0e25183116b..5bd90289d79 100644
--- a/src/mongo/dbtests/jstests.cpp
+++ b/src/mongo/dbtests/jstests.cpp
@@ -736,7 +736,7 @@ public:
ASSERT(s->exec((string) "y = " + outString, "foo2", false, true, false));
BSONObj out = s->getObject("y");
- ASSERT_EQUALS(in, out);
+ ASSERT_BSONOBJ_EQ(in, out);
}
};
@@ -847,7 +847,7 @@ public:
ASSERT(s->exec((string) "y = " + outString, "foo2", false, true, false));
BSONObj out = s->getObject("y");
- ASSERT_EQUALS(in, out);
+ ASSERT_BSONOBJ_EQ(in, out);
}
};
@@ -2183,7 +2183,7 @@ public:
{
BSONObjBuilder b;
s->append(b, "z", "x");
- ASSERT_EQUALS(BSON("z" << 5), b.obj());
+ ASSERT_BSONOBJ_EQ(BSON("z" << 5), b.obj());
}
s->invokeSafe("x = function(){ return 17; }", 0, 0);
diff --git a/src/mongo/dbtests/mock/mock_replica_set.cpp b/src/mongo/dbtests/mock/mock_replica_set.cpp
index 1df5d5b7dee..5005aec6f6c 100644
--- a/src/mongo/dbtests/mock/mock_replica_set.cpp
+++ b/src/mongo/dbtests/mock/mock_replica_set.cpp
@@ -304,7 +304,9 @@ void MockReplicaSet::mockReplSetGetStatusCmd() {
hostsField.push_back(hostMemberBuilder.obj());
}
- sort(hostsField.begin(), hostsField.end());
+ std::sort(hostsField.begin(),
+ hostsField.end(),
+ SimpleBSONObjComparator::kInstance.makeLessThan());
// TODO: syncingTo
diff --git a/src/mongo/dbtests/query_stage_delete.cpp b/src/mongo/dbtests/query_stage_delete.cpp
index 65f47ba7429..b487bc2c655 100644
--- a/src/mongo/dbtests/query_stage_delete.cpp
+++ b/src/mongo/dbtests/query_stage_delete.cpp
@@ -247,7 +247,7 @@ public:
ASSERT_TRUE(resultMember->obj.value().isOwned());
// Should be the old value.
- ASSERT_EQUALS(resultMember->obj.value(), oldDoc);
+ ASSERT_BSONOBJ_EQ(resultMember->obj.value(), oldDoc);
// Should have done the delete.
ASSERT_EQUALS(stats->docsDeleted, 1U);
diff --git a/src/mongo/dbtests/query_stage_ensure_sorted.cpp b/src/mongo/dbtests/query_stage_ensure_sorted.cpp
index 3053a0d7edc..9e930375317 100644
--- a/src/mongo/dbtests/query_stage_ensure_sorted.cpp
+++ b/src/mongo/dbtests/query_stage_ensure_sorted.cpp
@@ -104,7 +104,7 @@ public:
// Compare the results against what we expect.
BSONObj expectedObj = fromjson(expectedStr);
- ASSERT_EQ(outputObj, expectedObj);
+ ASSERT_BSONOBJ_EQ(outputObj, expectedObj);
}
protected:
diff --git a/src/mongo/dbtests/query_stage_ixscan.cpp b/src/mongo/dbtests/query_stage_ixscan.cpp
index 9167ba0023b..3d22cf19fd9 100644
--- a/src/mongo/dbtests/query_stage_ixscan.cpp
+++ b/src/mongo/dbtests/query_stage_ixscan.cpp
@@ -168,7 +168,7 @@ public:
static_cast<const IndexScanStats*>(ixscan->getSpecificStats());
ASSERT(stats);
ASSERT_TRUE(stats->isMultiKey);
- ASSERT_EQUALS(stats->keyPattern, BSON("x" << 1));
+ ASSERT_BSONOBJ_EQ(stats->keyPattern, BSON("x" << 1));
}
};
@@ -188,10 +188,10 @@ public:
// Expect to get key {'': 5} and then key {'': 6}.
WorkingSetMember* member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 5));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 5));
member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 6));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 6));
// Save state and insert a few indexed docs.
ixscan->saveState();
@@ -201,7 +201,7 @@ public:
member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 10));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 10));
WorkingSetID id;
ASSERT_EQ(PlanStage::IS_EOF, ixscan->work(&id));
@@ -225,7 +225,7 @@ public:
// Expect to get key {'': 6}.
WorkingSetMember* member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 6));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 6));
// Save state and insert an indexed doc.
ixscan->saveState();
@@ -234,7 +234,7 @@ public:
member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 7));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 7));
WorkingSetID id;
ASSERT_EQ(PlanStage::IS_EOF, ixscan->work(&id));
@@ -258,7 +258,7 @@ public:
// Expect to get key {'': 6}.
WorkingSetMember* member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 6));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 6));
// Save state and insert an indexed doc.
ixscan->saveState();
@@ -288,10 +288,10 @@ public:
// Expect to get key {'': 10} and then {'': 8}.
WorkingSetMember* member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 10));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 10));
member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 8));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 8));
// Save state and insert an indexed doc.
ixscan->saveState();
@@ -302,7 +302,7 @@ public:
// Ensure that we don't erroneously return {'': 9} or {'':3}.
member = getNext(ixscan.get());
ASSERT_EQ(WorkingSetMember::RID_AND_IDX, member->getState());
- ASSERT_EQ(member->keyData[0].keyData, BSON("" << 6));
+ ASSERT_BSONOBJ_EQ(member->keyData[0].keyData, BSON("" << 6));
WorkingSetID id;
ASSERT_EQ(PlanStage::IS_EOF, ixscan->work(&id));
diff --git a/src/mongo/dbtests/query_stage_merge_sort.cpp b/src/mongo/dbtests/query_stage_merge_sort.cpp
index 3e95a7da805..d2a9139b2c6 100644
--- a/src/mongo/dbtests/query_stage_merge_sort.cpp
+++ b/src/mongo/dbtests/query_stage_merge_sort.cpp
@@ -706,7 +706,7 @@ public:
member = getNextResult(&ws, ms.get());
ASSERT_EQ(member->getState(), WorkingSetMember::RID_AND_OBJ);
ASSERT_EQ(member->recordId, *it);
- ASSERT_EQ(member->obj.value(), BSON("_id" << 4 << "a" << 4));
+ ASSERT_BSONOBJ_EQ(member->obj.value(), BSON("_id" << 4 << "a" << 4));
++it;
// Doc {a: 5} gets invalidated by an update.
@@ -715,14 +715,14 @@ public:
// Invalidated doc {a: 5} should still get returned.
member = getNextResult(&ws, ms.get());
ASSERT_EQ(member->getState(), WorkingSetMember::OWNED_OBJ);
- ASSERT_EQ(member->obj.value(), BSON("_id" << 5 << "a" << 5));
+ ASSERT_BSONOBJ_EQ(member->obj.value(), BSON("_id" << 5 << "a" << 5));
++it;
// We correctly dedup the invalidated doc and return {a: 6} next.
member = getNextResult(&ws, ms.get());
ASSERT_EQ(member->getState(), WorkingSetMember::RID_AND_OBJ);
ASSERT_EQ(member->recordId, *it);
- ASSERT_EQ(member->obj.value(), BSON("_id" << 6 << "a" << 6));
+ ASSERT_BSONOBJ_EQ(member->obj.value(), BSON("_id" << 6 << "a" << 6));
}
private:
diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp
index 04fdbb1c6b2..53c839d0fd4 100644
--- a/src/mongo/dbtests/query_stage_subplan.cpp
+++ b/src/mongo/dbtests/query_stage_subplan.cpp
@@ -564,8 +564,10 @@ public:
++numResults;
WorkingSetMember* member = ws.get(id);
ASSERT(member->hasObj());
- ASSERT(member->obj.value() == BSON("_id" << 1 << "a" << 1 << "b" << 2) ||
- member->obj.value() == BSON("_id" << 3 << "a" << 1 << "c" << 3));
+ ASSERT(SimpleBSONObjComparator::kInstance.evaluate(
+ member->obj.value() == BSON("_id" << 1 << "a" << 1 << "b" << 2)) ||
+ SimpleBSONObjComparator::kInstance.evaluate(
+ member->obj.value() == BSON("_id" << 3 << "a" << 1 << "c" << 3)));
}
}
diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp
index 8c2897d7ac1..6d2b2842465 100644
--- a/src/mongo/dbtests/query_stage_update.cpp
+++ b/src/mongo/dbtests/query_stage_update.cpp
@@ -234,7 +234,7 @@ public:
// Expect a single document, {_id: 0, x: 1, y: 2}.
ASSERT_EQUALS(1U, objs.size());
- ASSERT_EQUALS(objs[0], fromjson("{_id: 0, x: 1, y: 2}"));
+ ASSERT_BSONOBJ_EQ(objs[0], fromjson("{_id: 0, x: 1, y: 2}"));
}
}
};
@@ -429,13 +429,13 @@ public:
ASSERT_TRUE(resultMember->obj.value().isOwned());
// Should be the old value.
- ASSERT_EQUALS(resultMember->obj.value(), oldDoc);
+ ASSERT_BSONOBJ_EQ(resultMember->obj.value(), oldDoc);
// Should have done the update.
BSONObj newDoc = BSON("_id" << targetDocIndex << "foo" << targetDocIndex << "x" << 0);
vector<BSONObj> objs;
getCollContents(coll, &objs);
- ASSERT_EQUALS(objs[targetDocIndex], newDoc);
+ ASSERT_BSONOBJ_EQ(objs[targetDocIndex], newDoc);
// That should be it.
id = WorkingSet::INVALID_ID;
@@ -518,12 +518,12 @@ public:
// Should be the new value.
BSONObj newDoc = BSON("_id" << targetDocIndex << "foo" << targetDocIndex << "x" << 0);
- ASSERT_EQUALS(resultMember->obj.value(), newDoc);
+ ASSERT_BSONOBJ_EQ(resultMember->obj.value(), newDoc);
// Should have done the update.
vector<BSONObj> objs;
getCollContents(coll, &objs);
- ASSERT_EQUALS(objs[targetDocIndex], newDoc);
+ ASSERT_BSONOBJ_EQ(objs[targetDocIndex], newDoc);
// That should be it.
id = WorkingSet::INVALID_ID;
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index 9523e4e5820..cdcca08b505 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -136,7 +136,7 @@ public:
ASSERT(Helpers::findOne(&_txn, _collection, query, ret, true));
ASSERT_EQUALS(string("b"), ret.firstElement().fieldName());
// Cross check with findOne() returning location.
- ASSERT_EQUALS(
+ ASSERT_BSONOBJ_EQ(
ret,
_collection->docFor(&_txn, Helpers::findOne(&_txn, _collection, query, true)).value());
}
@@ -152,7 +152,7 @@ public:
// Check findOne() returning object, allowing unindexed scan.
ASSERT(Helpers::findOne(&_txn, _collection, query, ret, false));
// Check findOne() returning location, allowing unindexed scan.
- ASSERT_EQUALS(
+ ASSERT_BSONOBJ_EQ(
ret,
_collection->docFor(&_txn, Helpers::findOne(&_txn, _collection, query, false)).value());
@@ -166,7 +166,7 @@ public:
// Check findOne() returning object, requiring indexed scan with index.
ASSERT(Helpers::findOne(&_txn, _collection, query, ret, true));
// Check findOne() returning location, requiring indexed scan with index.
- ASSERT_EQUALS(
+ ASSERT_BSONOBJ_EQ(
ret,
_collection->docFor(&_txn, Helpers::findOne(&_txn, _collection, query, true)).value());
}
@@ -208,7 +208,7 @@ public:
BSONObj ret;
ASSERT(Helpers::findOne(&_txn, _collection, query, ret, false));
ASSERT(ret.isEmpty());
- ASSERT_EQUALS(
+ ASSERT_BSONOBJ_EQ(
ret,
_collection->docFor(&_txn, Helpers::findOne(&_txn, _collection, query, false)).value());
}
@@ -1730,8 +1730,8 @@ namespace queryobjecttests {
class names1 {
public:
void run() {
- ASSERT_EQUALS(BSON("x" << 1), QUERY("query" << BSON("x" << 1)).getFilter());
- ASSERT_EQUALS(BSON("x" << 1), QUERY("$query" << BSON("x" << 1)).getFilter());
+ ASSERT_BSONOBJ_EQ(BSON("x" << 1), QUERY("query" << BSON("x" << 1)).getFilter());
+ ASSERT_BSONOBJ_EQ(BSON("x" << 1), QUERY("$query" << BSON("x" << 1)).getFilter());
}
};
}
diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp
index 10996568f12..326dffb364b 100644
--- a/src/mongo/dbtests/repltests.cpp
+++ b/src/mongo/dbtests/repltests.cpp
@@ -130,7 +130,7 @@ protected:
::mongo::log() << "expected: " << expected.toString() << ", got: " << got.toString()
<< endl;
}
- ASSERT_EQUALS(expected, got);
+ ASSERT_BSONOBJ_EQ(expected, got);
}
BSONObj oneOp() const {
return _client.findOne(cllNS(), BSONObj());
diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp
index f437cb68c64..99d90fec617 100644
--- a/src/mongo/dbtests/rollbacktests.cpp
+++ b/src/mongo/dbtests/rollbacktests.cpp
@@ -97,7 +97,7 @@ void assertOnlyRecord(OperationContext* txn, const NamespaceString& nss, const B
auto record = cursor->next();
ASSERT(record);
- ASSERT_EQ(data, record->data.releaseToBson());
+ ASSERT_BSONOBJ_EQ(data, record->data.releaseToBson());
ASSERT(!cursor->next());
}
diff --git a/src/mongo/dbtests/sort_key_generator_test.cpp b/src/mongo/dbtests/sort_key_generator_test.cpp
index 84a02e9525d..c808a52623a 100644
--- a/src/mongo/dbtests/sort_key_generator_test.cpp
+++ b/src/mongo/dbtests/sort_key_generator_test.cpp
@@ -102,13 +102,13 @@ BSONObj extractSortKeyCovered(const char* sortSpec,
TEST(SortKeyGeneratorTest, SortKeyNormal) {
BSONObj actualOut = extractSortKey("{a: 1}", "{_id: 0, a: 5}", "", nullptr);
BSONObj expectedOut = BSON("" << 5);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyNormal2) {
BSONObj actualOut = extractSortKey("{a: 1}", "{_id: 0, z: 10, a: 6, b: 16}", "", nullptr);
BSONObj expectedOut = BSON("" << 6);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyString) {
@@ -116,28 +116,28 @@ TEST(SortKeyGeneratorTest, SortKeyString) {
extractSortKey("{a: 1}", "{_id: 0, z: 'thing1', a: 'thing2', b: 16}", "", nullptr);
BSONObj expectedOut = BSON(""
<< "thing2");
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyCompound) {
BSONObj actualOut = extractSortKey(
"{a: 1, b: 1}", "{_id: 0, z: 'thing1', a: 99, c: {a: 4}, b: 16}", "", nullptr);
BSONObj expectedOut = BSON("" << 99 << "" << 16);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyEmbedded) {
BSONObj actualOut = extractSortKey(
"{'c.a': 1, b: 1}", "{_id: 0, z: 'thing1', a: 99, c: {a: 4}, b: 16}", "", nullptr);
BSONObj expectedOut = BSON("" << 4 << "" << 16);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyArray) {
BSONObj actualOut = extractSortKey(
"{'c': 1, b: 1}", "{_id: 0, z: 'thing1', a: 99, c: [2, 4, 1], b: 16}", "", nullptr);
BSONObj expectedOut = BSON("" << 1 << "" << 16);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyCoveredNormal) {
@@ -145,7 +145,7 @@ TEST(SortKeyGeneratorTest, SortKeyCoveredNormal) {
BSONObj actualOut = extractSortKeyCovered(
"{a: 1}", IndexKeyDatum(BSON("a" << 1), BSON("" << 5), nullptr), collator);
BSONObj expectedOut = BSON("" << 5);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyCoveredEmbedded) {
@@ -155,7 +155,7 @@ TEST(SortKeyGeneratorTest, SortKeyCoveredEmbedded) {
IndexKeyDatum(BSON("a.c" << 1 << "c" << 1), BSON("" << 5 << "" << 6), nullptr),
collator);
BSONObj expectedOut = BSON("" << 5);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyCoveredCompound) {
@@ -165,7 +165,7 @@ TEST(SortKeyGeneratorTest, SortKeyCoveredCompound) {
IndexKeyDatum(BSON("a" << 1 << "c" << 1), BSON("" << 5 << "" << 6), nullptr),
collator);
BSONObj expectedOut = BSON("" << 5 << "" << 6);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyCoveredCompound2) {
@@ -176,7 +176,7 @@ TEST(SortKeyGeneratorTest, SortKeyCoveredCompound2) {
nullptr),
collator);
BSONObj expectedOut = BSON("" << 5 << "" << 6);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyCoveredCompound3) {
@@ -188,7 +188,7 @@ TEST(SortKeyGeneratorTest, SortKeyCoveredCompound3) {
nullptr),
collator);
BSONObj expectedOut = BSON("" << 6 << "" << 4);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, ExtractStringSortKeyWithCollatorUsesComparisonKey) {
@@ -197,14 +197,14 @@ TEST(SortKeyGeneratorTest, ExtractStringSortKeyWithCollatorUsesComparisonKey) {
extractSortKey("{a: 1}", "{_id: 0, z: 'thing1', a: 'thing2', b: 16}", "", &collator);
BSONObj expectedOut = BSON(""
<< "2gniht");
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, CollatorHasNoEffectWhenExtractingNonStringSortKey) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
BSONObj actualOut = extractSortKey("{a: 1}", "{_id: 0, z: 10, a: 6, b: 16}", "", &collator);
BSONObj expectedOut = BSON("" << 6);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, CollatorHasNoAffectWhenExtractingCoveredSortKey) {
@@ -217,14 +217,14 @@ TEST(SortKeyGeneratorTest, CollatorHasNoAffectWhenExtractingCoveredSortKey) {
&collator);
BSONObj expectedOut = BSON(""
<< "foo");
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, SortKeyGenerationForArraysUsesTheQueryPredicate) {
BSONObj actualOut =
extractSortKey("{a: -1}", "{_id: 0, a: [1, 2, 3, 4]}", "{a: {$lt: 3}}", nullptr);
BSONObj expectedOut = BSON("" << 2);
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, EnsureSortKeyGenerationForArraysRespectsCollation) {
@@ -233,7 +233,7 @@ TEST(SortKeyGeneratorTest, EnsureSortKeyGenerationForArraysRespectsCollation) {
extractSortKey("{a: 1}", "{_id: 0, a: ['aaz', 'zza', 'yya', 'zzb']}", "", &collator);
BSONObj expectedOut = BSON(""
<< "ayy");
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
TEST(SortKeyGeneratorTest, EnsureSortKeyGenerationForArraysWithPredicateRespectsCollation) {
@@ -242,7 +242,7 @@ TEST(SortKeyGeneratorTest, EnsureSortKeyGenerationForArraysWithPredicateRespects
"{a: 1}", "{_id: 0, a: ['aaz', 'zza', 'yya', 'zzb']}", "{a: {$gt: 'yya'}}", &collator);
BSONObj expectedOut = BSON(""
<< "azz");
- ASSERT_EQ(actualOut, expectedOut);
+ ASSERT_BSONOBJ_EQ(actualOut, expectedOut);
}
} // namespace
diff --git a/src/mongo/dbtests/updatetests.cpp b/src/mongo/dbtests/updatetests.cpp
index a8075f42cd9..494c590f1d5 100644
--- a/src/mongo/dbtests/updatetests.cpp
+++ b/src/mongo/dbtests/updatetests.cpp
@@ -347,7 +347,7 @@ public:
_client.insert(ns(), initial);
_client.update(
ns(), initial, BSON("$setOnInsert" << BSON("a.b" << 1) << "$set" << BSON("d" << 1)));
- ASSERT_EQUALS(_client.findOne(ns(), initial), final);
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), initial), final);
}
};
@@ -497,7 +497,7 @@ public:
Query(),
BSON("$set" << BSON("z.0"
<< "a")));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,z:['a','b']}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,z:['a','b']}"));
}
};
@@ -515,7 +515,7 @@ public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
_client.update(ns(), Query(), BSON("$set" << BSON("a" << 2 << "a.b" << 1)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0}"));
}
};
@@ -557,7 +557,7 @@ public:
void run() {
_client.insert(ns(), fromjson("{'_id':0,a:[1]}"));
_client.update(ns(), Query(), BSON("$push" << BSON("a" << 5)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,5]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,5]}"));
}
};
@@ -584,7 +584,7 @@ public:
void run() {
_client.insert(ns(), fromjson("{'_id':0}"));
_client.update(ns(), Query(), BSON("$push" << BSON("a" << 5)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[5]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[5]}"));
}
};
@@ -650,7 +650,7 @@ public:
// { $push : { a : { $each : [ 2, 3 ] } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(2 << 3));
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2,3]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2,3]}"));
}
};
@@ -661,7 +661,7 @@ public:
// { $push : { a : { $each : [ 1, 2, 3 ] } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1 << 2 << 3));
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2,3]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2,3]}"));
}
};
@@ -672,7 +672,7 @@ public:
// { $push : { a : { $each : [ 2 ] , $slice : -3 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(2) << "$slice" << -3);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
}
};
@@ -683,7 +683,7 @@ public:
// { $push : { a : { $each : [ 2 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(2) << "$slice" << -2);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
}
};
@@ -694,7 +694,7 @@ public:
// { $push : { a : { $each : [ 2 , 3 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(2 << 3) << "$slice" << -2);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -705,7 +705,7 @@ public:
// { $push : { a : { $each : [ 3 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << -2);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -716,7 +716,7 @@ public:
// { $push : { a : { $each : [ 3 ] , $slice : 0 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << 0);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[]}"));
}
};
@@ -727,7 +727,7 @@ public:
// { $push : { a : { $each : [ 3 ] , $slice : 0 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << 0);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[]}"));
}
};
@@ -738,7 +738,7 @@ public:
// { $push : { a : { $each : [ 1 , 2 ] , $slice : -3 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1 << 2) << "$slice" << -3);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1,2]}"));
}
};
@@ -749,7 +749,7 @@ public:
// { $push : { a : { $each : [ 1 , 2 , 3 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1 << 2 << 3) << "$slice" << -2);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -760,7 +760,7 @@ public:
// { $push : { a : { $each : [ 1 ] , $slice : -3 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1) << "$slice" << -3);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[1]}"));
}
};
@@ -771,7 +771,7 @@ public:
// { $push : { a : { $each : [ 1 , 2 , 3 ] , $slice : -2 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(1 << 2 << 3) << "$slice" << -2);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -783,7 +783,7 @@ public:
BSONObj objA = BSON("$each" << BSON_ARRAY(5) << "$slice" << -2);
BSONObj objB = BSON("$each" << BSON_ARRAY(6) << "$slice" << -1);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << objA << "b" << objB)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,5],b:[6]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,5],b:[6]}"));
}
};
@@ -794,7 +794,7 @@ public:
// { $push : { a : { $each : [ 5 ] , $slice : -2 } , { b : 4 } }
BSONObj objA = BSON("$each" << BSON_ARRAY(5) << "$slice" << -2);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << objA << "b" << 4)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,5],b:[3,4]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,5],b:[3,4]}"));
}
};
@@ -873,7 +873,7 @@ public:
// { $push : { a : { $each : [ 3 ], $slice : -2.0 } } }
BSONObj pushObj = BSON("$each" << BSON_ARRAY(3) << "$slice" << -2.0);
_client.update(ns(), Query(), BSON("$push" << BSON("a" << pushObj)));
- ASSERT_EQUALS(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
+ ASSERT_BSONOBJ_EQ(_client.findOne(ns(), Query()), fromjson("{'_id':0,a:[2,3]}"));
}
};
@@ -1014,7 +1014,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:1,b:1},{a:2,b:2}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
@@ -1022,7 +1022,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
}
}
@@ -1059,7 +1059,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:1,b:1},{a:2,b:2}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
@@ -1067,7 +1067,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
}
}
@@ -1103,14 +1103,14 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:3,b:3}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case BOTTOMK_ASC:
@@ -1150,7 +1150,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
}
};
@@ -1183,7 +1183,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
}
};
@@ -1220,7 +1220,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:1,b:1},{a:2,b:2}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
@@ -1228,7 +1228,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
}
}
@@ -1265,14 +1265,14 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:3,b:3}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case BOTTOMK_ASC:
@@ -1315,7 +1315,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:1,b:1},{a:2,b:2}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
@@ -1323,7 +1323,7 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
}
}
@@ -1360,14 +1360,14 @@ public:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:3,b:3}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case TOPK_DESC:
_client.update(ns(), Query(), getUpdate(i));
result = _client.findOne(ns(), Query());
expected = fromjson("{'_id':0,x:[{a:2,b:2},{a:1,b:1}]}");
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
break;
case BOTTOMK_ASC:
@@ -1417,9 +1417,9 @@ public:
sort(workArea.begin(), workArea.end(), ProjectKeyCmp(BSON("b" << 1 << "a" << -1)));
- ASSERT_EQUALS(workArea[0], objs[1]);
- ASSERT_EQUALS(workArea[1], objs[0]);
- ASSERT_EQUALS(workArea[2], objs[2]);
+ ASSERT_BSONOBJ_EQ(workArea[0], objs[1]);
+ ASSERT_BSONOBJ_EQ(workArea[1], objs[0]);
+ ASSERT_BSONOBJ_EQ(workArea[2], objs[2]);
}
};
@@ -1438,9 +1438,9 @@ public:
sort(workArea.begin(), workArea.end(), ProjectKeyCmp(BSON("a" << 1 << "b" << 1)));
- ASSERT_EQUALS(workArea[0], objs[0]);
- ASSERT_EQUALS(workArea[1], objs[2]);
- ASSERT_EQUALS(workArea[2], objs[1]);
+ ASSERT_BSONOBJ_EQ(workArea[0], objs[0]);
+ ASSERT_BSONOBJ_EQ(workArea[1], objs[2]);
+ ASSERT_BSONOBJ_EQ(workArea[2], objs[1]);
}
};
@@ -1459,9 +1459,9 @@ public:
sort(workArea.begin(), workArea.end(), ProjectKeyCmp(BSON("a" << 1 << "b" << 1)));
- ASSERT_EQUALS(workArea[0], objs[0]);
- ASSERT_EQUALS(workArea[1], objs[2]);
- ASSERT_EQUALS(workArea[2], objs[1]);
+ ASSERT_BSONOBJ_EQ(workArea[0], objs[0]);
+ ASSERT_BSONOBJ_EQ(workArea[1], objs[2]);
+ ASSERT_BSONOBJ_EQ(workArea[2], objs[1]);
}
};
@@ -1480,9 +1480,9 @@ public:
sort(workArea.begin(), workArea.end(), ProjectKeyCmp(BSON("b" << 1 << "c" << 1)));
- ASSERT_EQUALS(workArea[0], objs[1]);
- ASSERT_EQUALS(workArea[1], objs[0]);
- ASSERT_EQUALS(workArea[2], objs[2]);
+ ASSERT_BSONOBJ_EQ(workArea[0], objs[1]);
+ ASSERT_BSONOBJ_EQ(workArea[1], objs[0]);
+ ASSERT_BSONOBJ_EQ(workArea[2], objs[2]);
}
};
@@ -1501,15 +1501,15 @@ public:
sort(workArea.begin(), workArea.end(), ProjectKeyCmp(fromjson("{'a.b.d':-1}")));
- ASSERT_EQUALS(workArea[0], objs[1]);
- ASSERT_EQUALS(workArea[1], objs[2]);
- ASSERT_EQUALS(workArea[2], objs[0]);
+ ASSERT_BSONOBJ_EQ(workArea[0], objs[1]);
+ ASSERT_BSONOBJ_EQ(workArea[1], objs[2]);
+ ASSERT_BSONOBJ_EQ(workArea[2], objs[0]);
sort(workArea.begin(), workArea.end(), ProjectKeyCmp(fromjson("{'a.b':1}")));
- ASSERT_EQUALS(workArea[0], objs[1]);
- ASSERT_EQUALS(workArea[1], objs[0]);
- ASSERT_EQUALS(workArea[2], objs[2]);
+ ASSERT_BSONOBJ_EQ(workArea[0], objs[1]);
+ ASSERT_BSONOBJ_EQ(workArea[1], objs[0]);
+ ASSERT_BSONOBJ_EQ(workArea[2], objs[2]);
}
};
@@ -1527,7 +1527,7 @@ public:
<< BSON("a..d" << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {a.:1} } } }
@@ -1535,28 +1535,28 @@ public:
<< BSON("a." << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {.b:1} } } }
pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON(".b" << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {.:1} } } }
pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON("." << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
// { $push : { x : { $each : [ {a:3} ], $slice:-2, $sort : {'':1} } } }
pushObj = BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort"
<< BSON("" << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1570,7 +1570,7 @@ public:
BSON("$each" << BSON_ARRAY(3) << "$slice" << -2 << "$sort" << BSON("a" << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1584,7 +1584,7 @@ public:
BSON("$each" << BSON_ARRAY(BSON("a" << 3)) << "$slice" << -2 << "$sort" << 2);
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1598,7 +1598,7 @@ public:
<< BSON("a" << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1612,7 +1612,7 @@ public:
<< BSON("a" << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1626,7 +1626,7 @@ public:
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj expected = fromjson("{'_id':0,x:[{a:2},{a:3}]}");
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1640,7 +1640,7 @@ public:
<< BSON_ARRAY(2 << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1654,7 +1654,7 @@ public:
<< BSON("a" << 10));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1668,7 +1668,7 @@ public:
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj expected = fromjson("{'_id':0,x:[{a:2},{a:3}]}");
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1683,7 +1683,7 @@ public:
<< BSON("a" << 1));
_client.update(ns(), Query(), BSON("$push" << BSON("x" << pushObj)));
BSONObj result = _client.findOne(ns(), Query());
- ASSERT_EQUALS(result, expected);
+ ASSERT_BSONOBJ_EQ(result, expected);
}
};
@@ -1720,9 +1720,10 @@ public:
ASSERT_OK(dbtests::createIndex(&_txn, ns(), BSON("a" << 1)));
_client.insert(ns(), fromjson("{'_id':0}"));
_client.update(ns(), Query(), fromjson("{$set:{'a.b':4}}"));
- ASSERT_EQUALS(fromjson("{'_id':0,a:{b:4}}"), _client.findOne(ns(), Query()));
- ASSERT_EQUALS(fromjson("{'_id':0,a:{b:4}}"),
- _client.findOne(ns(), fromjson("{'a.b':4}"))); // make sure the index works
+ ASSERT_BSONOBJ_EQ(fromjson("{'_id':0,a:{b:4}}"), _client.findOne(ns(), Query()));
+ ASSERT_BSONOBJ_EQ(
+ fromjson("{'_id':0,a:{b:4}}"),
+ _client.findOne(ns(), fromjson("{'a.b':4}"))); // make sure the index works
}
};
@@ -1759,11 +1760,11 @@ public:
_client.insert(
ns(), BSON("_id" << 0 << "a" << 1 << "x" << BSONObj() << "x" << BSONObj() << "z" << 5));
_client.update(ns(), BSONObj(), BSON("$set" << BSON("x.b" << 1 << "x.c" << 1)));
- ASSERT_EQUALS(BSON("_id" << 0 << "a" << 1 << "x" << BSON("b" << 1 << "c" << 1) << "x"
- << BSONObj()
- << "z"
- << 5),
- _client.findOne(ns(), BSONObj()));
+ ASSERT_BSONOBJ_EQ(BSON("_id" << 0 << "a" << 1 << "x" << BSON("b" << 1 << "c" << 1) << "x"
+ << BSONObj()
+ << "z"
+ << 5),
+ _client.findOne(ns(), BSONObj()));
}
};
@@ -1775,11 +1776,11 @@ public:
ns(), BSON("_id" << 0 << "x" << BSONObj() << "x" << BSONObj() << "x" << BSONObj()));
_client.update(
ns(), BSONObj(), BSON("$set" << BSON("x.b" << 1 << "x.c" << 1 << "x.d" << 1)));
- ASSERT_EQUALS(BSON("_id" << 0 << "x" << BSON("b" << 1 << "c" << 1 << "d" << 1) << "x"
- << BSONObj()
- << "x"
- << BSONObj()),
- _client.findOne(ns(), BSONObj()));
+ ASSERT_BSONOBJ_EQ(BSON("_id" << 0 << "x" << BSON("b" << 1 << "c" << 1 << "d" << 1) << "x"
+ << BSONObj()
+ << "x"
+ << BSONObj()),
+ _client.findOne(ns(), BSONObj()));
}
};
@@ -1820,7 +1821,7 @@ protected:
_client.dropCollection(ns());
insert(initial);
update(mod);
- ASSERT_EQUALS(after, findOne());
+ ASSERT_BSONOBJ_EQ(after, findOne());
_client.dropCollection(ns());
}