dynamic mergeObj2 = folly::dynamic::object
("key2", "value3")
("key3", "value4");
- dynamic combinedObj = folly::dynamic::object
+
+ // Merged object where we prefer the values in mergeObj2
+ dynamic combinedPreferObj2 = folly::dynamic::object
("key1", "value1")
("key2", "value3")
("key3", "value4");
+
+ // Merged object where we prefer the values in mergeObj1
+ dynamic combinedPreferObj1 = folly::dynamic::object
+ ("key1", "value1")
+ ("key2", "value2")
+ ("key3", "value4");
+
auto newMergeObj = dynamic::merge(mergeObj1, mergeObj2);
- EXPECT_EQ(newMergeObj, combinedObj);
+ EXPECT_EQ(newMergeObj, combinedPreferObj2);
EXPECT_EQ(mergeObj1, origMergeObj1); // mergeObj1 should be unchanged
mergeObj1.update(mergeObj2);
- EXPECT_EQ(mergeObj1, combinedObj);
+ EXPECT_EQ(mergeObj1, combinedPreferObj2);
dynamic arr = { 1, 2, 3, 4, 5, 6 };
EXPECT_THROW(mergeObj1.update(arr), std::exception);
+
+ mergeObj1 = origMergeObj1; // reset it
+ mergeObj1.update_missing(mergeObj2);
+ EXPECT_EQ(mergeObj1, combinedPreferObj1);
}
TEST(Dynamic, ObjectErase) {