summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morrow <acm@10gen.com>2013-05-29 14:05:22 -0400
committerAndrew Morrow <acm@10gen.com>2013-06-01 12:40:17 -0400
commit0c3ca38ca7065f064608ac2a6e4c7822a0c822fb (patch)
tree9a39c0cd321fe027025c1246133242a8bdff449c
parent65811339dc36ac869e363c6366e8f013431f7de4 (diff)
downloadmongo-0c3ca38ca7065f064608ac2a6e4c7822a0c822fb.tar.gz
SERVER-7174 Cleanup and strengthen some new modifier tests
-rw-r--r--src/mongo/db/ops/modifier_add_to_set_test.cpp48
-rw-r--r--src/mongo/db/ops/modifier_bit_test.cpp165
-rw-r--r--src/mongo/db/ops/modifier_pull_test.cpp45
3 files changed, 209 insertions, 49 deletions
diff --git a/src/mongo/db/ops/modifier_add_to_set_test.cpp b/src/mongo/db/ops/modifier_add_to_set_test.cpp
index a7168eea53f..b40697a7fb0 100644
--- a/src/mongo/db/ops/modifier_add_to_set_test.cpp
+++ b/src/mongo/db/ops/modifier_add_to_set_test.cpp
@@ -136,6 +136,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1 ] } }"), logDoc);
}
TEST(SimpleMod, PrepareInvalidTargetNumber) {
@@ -165,11 +169,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 1 ] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 1 ] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [ 1 ] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1 ] } }"), logDoc);
}
TEST(SimpleMod, ApplyAndLogEmptyArray) {
@@ -183,11 +187,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 1 ] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 1 ] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [ 1 ] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1 ] } }"), logDoc);
}
TEST(SimpleEachMod, ApplyAndLogEmptyDocument) {
@@ -201,11 +205,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 1, 2, 3 ] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 1, 2, 3 ] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [ 1, 2, 3 ] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1, 2, 3 ] } }"), logDoc);
}
TEST(SimpleEachMod, ApplyAndLogEmptyArray) {
@@ -219,11 +223,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 1, 2, 3 ] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 1, 2, 3 ] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [ 1, 2, 3 ] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1, 2, 3 ] } }"), logDoc);
}
TEST(SimpleMod, ApplyAndLogPopulatedArray) {
@@ -237,11 +241,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 'x', 1 ] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 'x', 1 ] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [ 'x', 1 ] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 'x', 1 ] } }"), logDoc);
}
TEST(SimpleEachMod, ApplyAndLogPopulatedArray) {
@@ -255,11 +259,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 'x', 1, 2, 3 ] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 'x', 1, 2, 3 ] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [ 'x', 1, 2, 3 ] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 'x', 1, 2, 3 ] } }"), logDoc);
}
TEST(NoOp, AddOneExistingIsNoOp) {
@@ -270,6 +274,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1, 2, 3 ] } }"), logDoc);
}
TEST(NoOp, AddSeveralExistingIsNoOp) {
@@ -280,6 +288,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1, 2, 3 ] } }"), logDoc);
}
TEST(NoOp, AddAllExistingIsNoOp) {
@@ -290,6 +302,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1, 2, 3 ] } }"), logDoc);
}
TEST(Deduplication, ExistingDuplicatesArePreserved) {
@@ -303,11 +319,11 @@ namespace {
ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 1, 1, 2, 1, 2, 2, 3] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 1, 1, 2, 1, 2, 2, 3] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [ 1, 1, 2, 1, 2, 2, 3] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1, 1, 2, 1, 2, 2, 3] } }"), logDoc);
}
TEST(Deduplication, NewDuplicatesAreElided) {
@@ -321,11 +337,11 @@ namespace {
ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 1, 1, 2, 1, 2, 2, 4, 3] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 1, 1, 2, 1, 2, 2, 4, 3] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [ 1, 1, 2, 1, 2, 2, 4, 3] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [ 1, 1, 2, 1, 2, 2, 4, 3] } }"), logDoc);
}
} // namespace
diff --git a/src/mongo/db/ops/modifier_bit_test.cpp b/src/mongo/db/ops/modifier_bit_test.cpp
index 24bb55c868a..f7e4289aec4 100644
--- a/src/mongo/db/ops/modifier_bit_test.cpp
+++ b/src/mongo/db/ops/modifier_bit_test.cpp
@@ -135,6 +135,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(fromjson("{ $set : { a : 1 } }"), logDoc);
}
TEST(SimpleMod, PrepareSimpleNonNumericObject) {
@@ -172,11 +176,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : 0 }")));
+ ASSERT_EQUALS(fromjson("{ a : 0 }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : 0 } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : 0 } }"), logDoc);
}
TEST(SimpleMod, ApplyAndLogEmptyDocumentOr) {
@@ -189,11 +193,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : 1 }")));
+ ASSERT_EQUALS(fromjson("{ a : 1 }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : 1 } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : 1 } }"), logDoc);
}
TEST(SimpleMod, ApplyAndLogSimpleDocumentAnd) {
@@ -206,11 +210,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : 4 }")));
+ ASSERT_EQUALS(fromjson("{ a : 4 }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : 4 } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : 4 } }"), logDoc);
}
TEST(SimpleMod, ApplyAndLogSimpleDocumentOr) {
@@ -223,11 +227,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : 7 }")));
+ ASSERT_EQUALS(fromjson("{ a : 7 }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : 7 } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : 7 } }"), logDoc);
}
TEST(InPlace, IntToIntAndIsInPlace) {
@@ -238,6 +242,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" << static_cast<int>(1))), logDoc);
}
TEST(InPlace, IntToIntOrIsInPlace) {
@@ -248,6 +256,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" << static_cast<int>(1))), logDoc);
}
TEST(InPlace, LongToLongAndIsInPlace) {
@@ -258,6 +270,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" << static_cast<long long>(1))), logDoc);
}
TEST(InPlace, LongToLongOrIsInPlace) {
@@ -268,6 +284,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" << static_cast<long long>(1))), logDoc);
}
TEST(InPlace, IntToLongAndIsNotInPlace) {
@@ -298,6 +318,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" << static_cast<int>(0xABCD1234U))), logDoc);
}
TEST(NoOp, IntOr) {
@@ -308,6 +332,10 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" << static_cast<int>(0xABCD1234U))), logDoc);
}
TEST(NoOp, LongAnd) {
@@ -318,6 +346,11 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" <<
+ static_cast<long long>(0xABCD1234EF981234ULL))), logDoc);
}
TEST(NoOp, LongOr) {
@@ -328,6 +361,11 @@ namespace {
ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
ASSERT_TRUE(execInfo.noOp);
ASSERT_TRUE(execInfo.inPlace);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" <<
+ static_cast<long long>(0xABCD1234EF981234ULL))), logDoc);
}
TEST(Upcasting, UpcastIntToLongAnd) {
@@ -340,7 +378,7 @@ namespace {
ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : 1 }")));
+ ASSERT_EQUALS(fromjson("{ a : 1 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
}
@@ -354,7 +392,7 @@ namespace {
ASSERT_FALSE(execInfo.inPlace);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : 1 }")));
+ ASSERT_EQUALS(fromjson("{ a : 1 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
}
@@ -368,7 +406,7 @@ namespace {
ASSERT_TRUE(execInfo.inPlace);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : 0 }")));
+ ASSERT_EQUALS(fromjson("{ a : 0 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
}
@@ -382,8 +420,111 @@ namespace {
ASSERT_TRUE(execInfo.inPlace);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : 3 }")));
+ ASSERT_EQUALS(fromjson("{ a : 3 }"), doc);
ASSERT_EQUALS(mongo::NumberLong, doc.root()["a"].getType());
}
+ // The following tests are re-created from the previous $bit tests in updatetests.cpp. They
+ // are probably redundant with the tests above in various ways.
+
+ TEST(DbUpdateTests, BitRewriteExistingField) {
+ Document doc(BSON("a" << static_cast<int>(0)));
+ Mod mod(BSON("$bit" << BSON("a" << BSON("or" << static_cast<int>(1)))));
+
+ ModifierInterface::ExecInfo execInfo;
+ ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
+ ASSERT_FALSE(execInfo.noOp);
+ ASSERT_TRUE(execInfo.inPlace);
+
+ ASSERT_OK(mod.apply());
+ ASSERT_EQUALS(BSON("a" << static_cast<int>(1)), doc);
+ ASSERT_EQUALS(mongo::NumberInt, doc.root()["a"].getType());
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("a" << static_cast<int>(1))), logDoc);
+ }
+
+ TEST(DbUpdateTests, BitRewriteNonExistingField) {
+ Document doc(BSON("a" << static_cast<int>(0)));
+ Mod mod(BSON("$bit" << BSON("b" << BSON("or" << static_cast<int>(1)))));
+
+ ModifierInterface::ExecInfo execInfo;
+ ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
+ ASSERT_FALSE(execInfo.noOp);
+ ASSERT_FALSE(execInfo.inPlace);
+
+ ASSERT_OK(mod.apply());
+ ASSERT_EQUALS(BSON("a" << static_cast<int>(0) << "b" << static_cast<int>(1)), doc);
+ ASSERT_EQUALS(mongo::NumberInt, doc.root()["a"].getType());
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(BSON("$set" << BSON("b" << static_cast<int>(1))), logDoc);
+ }
+
+ TEST(DbUpdateTests, Bit1_1) {
+ Document doc(BSON("_id" << 1 << "x" << 3));
+ Mod mod(BSON("$bit" << BSON("x" << BSON("and" << 2))));
+ const BSONObj result(BSON("_id" << 1 << "x" << (3 & 2)));
+
+ ModifierInterface::ExecInfo execInfo;
+ ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
+ if (!execInfo.noOp)
+ ASSERT_OK(mod.apply());
+
+ ASSERT_EQUALS(result, doc);
+ }
+
+ TEST(DbUpdateTests, Bit1_2) {
+ Document doc(BSON("_id" << 1 << "x" << 1));
+ Mod mod(BSON("$bit" << BSON("x" << BSON("or" << 4))));
+ const BSONObj result(BSON("_id" << 1 << "x" << (1 | 4)));
+
+ ModifierInterface::ExecInfo execInfo;
+ ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
+ if (!execInfo.noOp)
+ ASSERT_OK(mod.apply());
+
+ ASSERT_EQUALS(result, doc);
+ }
+
+ TEST(DbUpdateTests, Bit1_3) {
+ Document doc(BSON("_id" << 1 << "x" << 3));
+ Mod mod1(BSON("$bit" << BSON("x" << BSON("and" << 2))));
+ Mod mod2(BSON("$bit" << BSON("x" << BSON("or" << 8))));
+ const BSONObj result(BSON("_id" << 1 << "x" << ((3 & 2) | 8)));
+
+ ModifierInterface::ExecInfo execInfo1;
+ ASSERT_OK(mod1.prepare(doc.root(), "", &execInfo1));
+ if (!execInfo1.noOp)
+ ASSERT_OK(mod1.apply());
+
+ ModifierInterface::ExecInfo execInfo2;
+ ASSERT_OK(mod2.prepare(doc.root(), "", &execInfo2));
+ if (!execInfo2.noOp)
+ ASSERT_OK(mod2.apply());
+
+ ASSERT_EQUALS(result, doc);
+ }
+
+ TEST(DbUpdateTests, Bit1_4) {
+ Document doc(BSON("_id" << 1 << "x" << 3));
+ Mod mod1(BSON("$bit" << BSON("x" << BSON("or" << 2))));
+ Mod mod2(BSON("$bit" << BSON("x" << BSON("and" << 8))));
+ const BSONObj result(BSON("_id" << 1 << "x" << ((3 | 2) & 8)));
+
+ ModifierInterface::ExecInfo execInfo1;
+ ASSERT_OK(mod1.prepare(doc.root(), "", &execInfo1));
+ if (!execInfo1.noOp)
+ ASSERT_OK(mod1.apply());
+
+ ModifierInterface::ExecInfo execInfo2;
+ ASSERT_OK(mod2.prepare(doc.root(), "", &execInfo2));
+ if (!execInfo2.noOp)
+ ASSERT_OK(mod2.apply());
+
+ ASSERT_EQUALS(result, doc);
+ }
+
} // namespace
diff --git a/src/mongo/db/ops/modifier_pull_test.cpp b/src/mongo/db/ops/modifier_pull_test.cpp
index d79e05fb6b5..86a3954e961 100644
--- a/src/mongo/db/ops/modifier_pull_test.cpp
+++ b/src/mongo/db/ops/modifier_pull_test.cpp
@@ -80,6 +80,10 @@ namespace {
ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a");
ASSERT_TRUE(execInfo.inPlace);
ASSERT_TRUE(execInfo.noOp);
+
+ Document logDoc;
+ ASSERT_OK(mod.log(logDoc.root()));
+ ASSERT_EQUALS(fromjson("{ $unset : { a : 1 } }"), logDoc);
}
TEST(SimpleMod, PrepareOKTargetFound) {
@@ -121,7 +125,7 @@ namespace {
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $unset : { a : 1 } }")));
+ ASSERT_EQUALS(fromjson("{ $unset : { a : 1 } }"), logDoc);
}
TEST(SimpleMod, PrepareAndLogMissingElementAfterFoundPath) {
@@ -136,7 +140,7 @@ namespace {
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $unset : { 'a.b.c.d' : 1 } }")));
+ ASSERT_EQUALS(fromjson("{ $unset : { 'a.b.c.d' : 1 } }"), logDoc);
}
TEST(SimpleMod, PrepareAndLogEmptyArray) {
@@ -151,7 +155,7 @@ namespace {
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [] } }"), logDoc);
}
TEST(SimpleMod, PullMatchesNone) {
@@ -166,7 +170,7 @@ namespace {
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [2, 3, 4, 5] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [2, 3, 4, 5] } }"), logDoc);
}
TEST(SimpleMod, ApplyAndLogPullMatchesOne) {
@@ -180,11 +184,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 1, 2, 3, 4, 5 ] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 1, 2, 3, 4, 5 ] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [1, 2, 3, 4, 5] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [1, 2, 3, 4, 5] } }"), logDoc);
}
TEST(SimpleMod, ApplyAndLogPullMatchesSeveral) {
@@ -198,11 +202,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [ 1, 2, 3, 4, 5 ] }")));
+ ASSERT_EQUALS(fromjson("{ a : [ 1, 2, 3, 4, 5 ] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [1, 2, 3, 4, 5] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [1, 2, 3, 4, 5] } }"), logDoc);
}
TEST(SimpleMod, ApplyAndLogPullMatchesAll) {
@@ -216,11 +220,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson("{ a : [] }")));
+ ASSERT_EQUALS(fromjson("{ a : [] }"), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson("{ $set : { a : [] } }")));
+ ASSERT_EQUALS(fromjson("{ $set : { a : [] } }"), logDoc);
}
@@ -256,11 +260,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson(strings[2])));
+ ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson(strings[3])));
+ ASSERT_EQUALS(fromjson(strings[3]), logDoc);
}
TEST(ComplexMod, ApplyAndLogComplexDocAndMatching2) {
@@ -290,11 +294,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson(strings[2])));
+ ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson(strings[3])));
+ ASSERT_EQUALS(fromjson(strings[3]), logDoc);
}
#endif
@@ -324,11 +328,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson(strings[2])));
+ ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson(strings[3])));
+ ASSERT_EQUALS(fromjson(strings[3]), logDoc);
}
TEST(ValueMod, ApplyAndLogScalarValueMod) {
@@ -357,11 +361,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson(strings[2])));
+ ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson(strings[3])));
+ ASSERT_EQUALS(fromjson(strings[3]), logDoc);
}
TEST(ValueMod, ApplyAndLogObjectValueMod) {
@@ -390,12 +394,11 @@ namespace {
ASSERT_FALSE(execInfo.noOp);
ASSERT_OK(mod.apply());
- ASSERT_TRUE(checkDoc(doc, fromjson(strings[2])));
+ ASSERT_EQUALS(fromjson(strings[2]), doc);
Document logDoc;
ASSERT_OK(mod.log(logDoc.root()));
- ASSERT_TRUE(checkDoc(logDoc, fromjson(strings[3])));
+ ASSERT_EQUALS(fromjson(strings[3]), logDoc);
}
-
} // namespace