diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-06-01 11:31:13 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-06-01 11:31:13 +0200 |
commit | cd6e2dd7ab638487c462c40293a0d8db43fdb530 (patch) | |
tree | edf9cec58f4a0e995fd713089779ec5d0a14d134 /document/src/tests/documentupdatetestcase.cpp | |
parent | f7d0fe5fdfad579e867f01acc1d41b2ec77bd785 (diff) | |
parent | 5c57852b26126d72b080fb6e0893dc3d633c28c1 (diff) |
Merge with master
Diffstat (limited to 'document/src/tests/documentupdatetestcase.cpp')
-rw-r--r-- | document/src/tests/documentupdatetestcase.cpp | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index b6aca1ec8be..97dd916bc60 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -200,8 +200,6 @@ DocumentUpdateTest::testSimpleUsage() { ByteBuffer::UP docBuf = serialize42(docUpdate); docBuf->flip(); DocumentUpdate::UP docUpdateCopy(DocumentUpdate::create42(repo, *docBuf)); - CPPUNIT_ASSERT(!docUpdate.affectsDocumentBody()); - CPPUNIT_ASSERT(!docUpdateCopy->affectsDocumentBody()); // Create a test document Document doc(*docType, DocumentId("doc::testdoc")); @@ -252,7 +250,6 @@ DocumentUpdateTest::testSimpleUsage() { updated.getValue("intarr").release())); CPPUNIT_ASSERT_EQUAL(size_t(3), val->size()); CPPUNIT_ASSERT_EQUAL(4, (*val)[2].getAsInt()); - CPPUNIT_ASSERT(upd.affectsDocumentBody()); } { Document updated(doc); @@ -593,24 +590,21 @@ void DocumentUpdateTest::testReadSerializedFile() DocumentUpdate& upd(*updp); const DocumentType *type = repo.getDocumentType("serializetest"); - CPPUNIT_ASSERT_EQUAL(DocumentId(DocIdString("update", "test")), - upd.getId()); + CPPUNIT_ASSERT_EQUAL(DocumentId(DocIdString("update", "test")), upd.getId()); CPPUNIT_ASSERT_EQUAL(*type, upd.getType()); // Verify assign value update. - FieldUpdate serField = upd[0]; + FieldUpdate serField = upd.getUpdates()[0]; CPPUNIT_ASSERT_EQUAL(serField.getField().getId(), type->getField("intfield").getId()); const ValueUpdate* serValue = &serField[0]; CPPUNIT_ASSERT_EQUAL(serValue->getType(), ValueUpdate::Assign); - const AssignValueUpdate* assign( - static_cast<const AssignValueUpdate*>(serValue)); - CPPUNIT_ASSERT_EQUAL(IntFieldValue(4), - static_cast<const IntFieldValue&>(assign->getValue())); + const AssignValueUpdate* assign(static_cast<const AssignValueUpdate*>(serValue)); + CPPUNIT_ASSERT_EQUAL(IntFieldValue(4), static_cast<const IntFieldValue&>(assign->getValue())); // Verify clear field update. - serField = upd[1]; + serField = upd.getUpdates()[1]; CPPUNIT_ASSERT_EQUAL(serField.getField().getId(), type->getField("floatfield").getId()); serValue = &serField[0]; @@ -618,7 +612,7 @@ void DocumentUpdateTest::testReadSerializedFile() CPPUNIT_ASSERT(serValue->inherits(ClearValueUpdate::classId)); // Verify add value update. - serField = upd[2]; + serField = upd.getUpdates()[2]; CPPUNIT_ASSERT_EQUAL(serField.getField().getId(), type->getField("arrayoffloatfield").getId()); serValue = &serField[0]; @@ -765,14 +759,11 @@ DocumentUpdateTest::testUpdateArrayEmptyParamValue() TestDocMan docMan; Document::UP doc(docMan.createDocument()); const Field &field(doc->getType().getField("tags")); - CPPUNIT_ASSERT_EQUAL((document::FieldValue*) 0, - doc->getValue(field).get()); + CPPUNIT_ASSERT_EQUAL((document::FieldValue*) 0, doc->getValue(field).get()); // Assign array field with no array values = empty array. DocumentUpdate update(*doc->getDataType(), doc->getId()); - update.addUpdate(FieldUpdate(field) - .addUpdate(AssignValueUpdate( - ArrayFieldValue(field.getDataType())))); + update.addUpdate(FieldUpdate(field).addUpdate(AssignValueUpdate(ArrayFieldValue(field.getDataType())))); update.applyTo(*doc); // Verify that the field was set in the document. @@ -781,10 +772,9 @@ DocumentUpdateTest::testUpdateArrayEmptyParamValue() CPPUNIT_ASSERT_EQUAL((size_t) 0, fval1->size()); // Remove array field. - update.clear(); - update.addUpdate(FieldUpdate(field) - .addUpdate(ClearValueUpdate())); - update.applyTo(*doc); + DocumentUpdate update2(*doc->getDataType(), doc->getId()); + update2.addUpdate(FieldUpdate(field).addUpdate(ClearValueUpdate())); + update2.applyTo(*doc); // Verify that the field was cleared in the document. std::unique_ptr<ArrayFieldValue> fval2(doc->getAs<ArrayFieldValue>(field)); @@ -798,31 +788,25 @@ DocumentUpdateTest::testUpdateWeightedSetEmptyParamValue() TestDocMan docMan; Document::UP doc(docMan.createDocument()); const Field &field(doc->getType().getField("stringweightedset")); - CPPUNIT_ASSERT_EQUAL((document::FieldValue*) 0, - doc->getValue(field).get()); + CPPUNIT_ASSERT_EQUAL((document::FieldValue*) 0, doc->getValue(field).get()); // Assign weighted set with no items = empty set. DocumentUpdate update(*doc->getDataType(), doc->getId()); - update.addUpdate(FieldUpdate(field) - .addUpdate(AssignValueUpdate( - WeightedSetFieldValue(field.getDataType())))); + update.addUpdate(FieldUpdate(field).addUpdate(AssignValueUpdate(WeightedSetFieldValue(field.getDataType())))); update.applyTo(*doc); // Verify that the field was set in the document. - std::unique_ptr<WeightedSetFieldValue> - fval1(doc->getAs<WeightedSetFieldValue>(field)); + auto fval1(doc->getAs<WeightedSetFieldValue>(field)); CPPUNIT_ASSERT(fval1.get()); CPPUNIT_ASSERT_EQUAL((size_t) 0, fval1->size()); // Remove weighted set field. - update.clear(); - update.addUpdate(FieldUpdate(field) - .addUpdate(ClearValueUpdate())); - update.applyTo(*doc); + DocumentUpdate update2(*doc->getDataType(), doc->getId()); + update2.addUpdate(FieldUpdate(field).addUpdate(ClearValueUpdate())); + update2.applyTo(*doc); // Verify that the field was cleared in the document. - std::unique_ptr<WeightedSetFieldValue> - fval2(doc->getAs<WeightedSetFieldValue>(field)); + auto fval2(doc->getAs<WeightedSetFieldValue>(field)); CPPUNIT_ASSERT(!fval2); } @@ -833,8 +817,7 @@ DocumentUpdateTest::testUpdateArrayWrongSubtype() TestDocMan docMan; Document::UP doc(docMan.createDocument()); const Field &field(doc->getType().getField("tags")); - CPPUNIT_ASSERT_EQUAL((document::FieldValue*) 0, - doc->getValue(field).get()); + CPPUNIT_ASSERT_EQUAL((document::FieldValue*) 0, doc->getValue(field).get()); // Assign int values to string array. DocumentUpdate update(*doc->getDataType(), doc->getId()); |