summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/modifier_bit_test.cpp
diff options
context:
space:
mode:
authorApollon Oikonomopoulos <apoikos@debian.org>2018-03-22 12:08:05 +0200
committerApollon Oikonomopoulos <apoikos@debian.org>2018-03-22 12:08:05 +0200
commit72ad42c506a506ef238d4b1fdcf2b9da5668bfb9 (patch)
treedf94bdab3d6f16e14016f4547b9e86f368ba8150 /src/mongo/db/ops/modifier_bit_test.cpp
parent648fcfa3cf11ba8fdb7bb64c52f3159b4351ae3c (diff)
parentc49e99631589113663b1a3ac691870421965a315 (diff)
Update upstream source from tag 'upstream/3.4.14'
Update to upstream version '3.4.14' with Debian dir 8c079cd0bdbb1831aa5b89a3b7d4c1b4a1b891a2
Diffstat (limited to 'src/mongo/db/ops/modifier_bit_test.cpp')
-rw-r--r--src/mongo/db/ops/modifier_bit_test.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mongo/db/ops/modifier_bit_test.cpp b/src/mongo/db/ops/modifier_bit_test.cpp
index dbc4d7ba0b2..5b8b0131ea7 100644
--- a/src/mongo/db/ops/modifier_bit_test.cpp
+++ b/src/mongo/db/ops/modifier_bit_test.cpp
@@ -755,4 +755,41 @@ TEST(DbUpdateTests, Bit1_4_Combined) {
ASSERT_EQUALS(BSON("$set" << BSON("x" << ((3 | 2) & 8))), logDoc);
}
+TEST(IndexedMod, PrepareReportCreatedArrayElement) {
+ Document doc(fromjson("{a: [{b: 0}]}"));
+ Mod mod(fromjson("{$bit: {'a.1.c': {and: NumberInt(1)}}}"));
+
+ ModifierInterface::ExecInfo execInfo;
+ ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
+
+ ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.1.c");
+ ASSERT_TRUE(execInfo.indexOfArrayWithNewElement[0]);
+ ASSERT_EQUALS(*execInfo.indexOfArrayWithNewElement[0], 0u);
+ ASSERT_FALSE(execInfo.noOp);
+}
+
+TEST(IndexedMod, PrepareDoNotReportModifiedArrayElement) {
+ Document doc(fromjson("{a: [{b: NumberInt(0)}]}"));
+ Mod mod(fromjson("{$bit: {'a.0.c': {or: NumberInt(1)}}}"));
+
+ ModifierInterface::ExecInfo execInfo;
+ ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
+
+ ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.0.c");
+ ASSERT_FALSE(execInfo.indexOfArrayWithNewElement[0]);
+ ASSERT_FALSE(execInfo.noOp);
+}
+
+TEST(IndexedMod, PrepareDoNotReportCreatedNumericObjectField) {
+ Document doc(fromjson("{a: {'0': {b: 0}}}"));
+ Mod mod(fromjson("{$bit: {'a.1.c': {and: NumberInt(1)}}}"));
+
+ ModifierInterface::ExecInfo execInfo;
+ ASSERT_OK(mod.prepare(doc.root(), "", &execInfo));
+
+ ASSERT_EQUALS(execInfo.fieldRef[0]->dottedField(), "a.1.c");
+ ASSERT_FALSE(execInfo.indexOfArrayWithNewElement[0]);
+ ASSERT_FALSE(execInfo.noOp);
+}
+
} // namespace