diff options
author | Tor Brede Vekterli <vekterli@oath.com> | 2018-07-23 15:13:27 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@oath.com> | 2018-07-23 15:13:27 +0000 |
commit | 9eced38c7048128882fd1049468241c14ecefd17 (patch) | |
tree | f9383db83db4def94994fa115231a25a8d8d1f9b /document/src/tests/documentupdatetestcase.cpp | |
parent | a2b96031d9dd0df98169ad3d2ad6ce3b1710eefc (diff) |
Ignore array element update with index out of bounds
Only affects "element match" field value updates. Silently ignoring
the update matches the semantics of semantically identical field
path updates.
Diffstat (limited to 'document/src/tests/documentupdatetestcase.cpp')
-rw-r--r-- | document/src/tests/documentupdatetestcase.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index eea5dd4decf..b4d98f0dd21 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -64,6 +64,7 @@ struct DocumentUpdateTest : public CppUnit::TestFixture { void testThatCreateIfNonExistentFlagIsSerializedAndDeserialized(); void array_element_update_can_be_roundtrip_serialized(); void array_element_update_applies_to_specified_element(); + void array_element_update_for_invalid_index_is_ignored(); CPPUNIT_TEST_SUITE(DocumentUpdateTest); CPPUNIT_TEST(testSimpleUsage); @@ -91,6 +92,7 @@ struct DocumentUpdateTest : public CppUnit::TestFixture { CPPUNIT_TEST(testThatCreateIfNonExistentFlagIsSerializedAndDeserialized); CPPUNIT_TEST(array_element_update_can_be_roundtrip_serialized); CPPUNIT_TEST(array_element_update_applies_to_specified_element); + CPPUNIT_TEST(array_element_update_for_invalid_index_is_ignored); CPPUNIT_TEST_SUITE_END(); }; @@ -1050,4 +1052,17 @@ void DocumentUpdateTest::array_element_update_applies_to_specified_element() { CPPUNIT_ASSERT_EQUAL(vespalib::string("blarg"), (*result_array)[2].getAsString()); } +void DocumentUpdateTest::array_element_update_for_invalid_index_is_ignored() { + ArrayUpdateFixture f; + + ArrayFieldValue array_value(f.array_field.getDataType()); + array_value.add("jerry"); + f.doc->setValue(f.array_field, array_value); + + f.update->applyTo(*f.doc); // MapValueUpdate for index 1, which does not exist + + auto result_array = f.doc->getAs<ArrayFieldValue>(f.array_field); + CPPUNIT_ASSERT_EQUAL(array_value, *result_array); +} + } // namespace document |