summaryrefslogtreecommitdiffstats
path: root/document/src/tests
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-03-28 11:43:52 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-03-28 14:49:19 +0000
commit1cd2c6a3ba9e392c00b91bfe3cf1215a80c6679f (patch)
tree4cbcddcf8922d4a3447d0806bfab26d935e8ccbe /document/src/tests
parent8976efd142145482d61d83755db2fab0a8b626a6 (diff)
Remove copy constructors.
Diffstat (limited to 'document/src/tests')
-rw-r--r--document/src/tests/documentselectparsertest.cpp4
-rw-r--r--document/src/tests/documentupdatetestcase.cpp119
-rw-r--r--document/src/tests/feed_reject_helper_test.cpp10
-rw-r--r--document/src/tests/testxml.cpp14
4 files changed, 73 insertions, 74 deletions
diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp
index a447df1044e..70ebd9bd7a2 100644
--- a/document/src/tests/documentselectparsertest.cpp
+++ b/document/src/tests/documentselectparsertest.cpp
@@ -139,9 +139,9 @@ DocumentUpdate::SP DocumentSelectParserTest::createUpdate(
const DocumentType* type = _repo->getDocumentType(doctype);
auto doc = std::make_shared<DocumentUpdate>(*_repo, *type, DocumentId(id));
doc->addUpdate(FieldUpdate(doc->getType().getField("headerval"))
- .addUpdate(std::make_unique<AssignValueUpdate>(IntFieldValue(hint))));
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<IntFieldValue>(hint))));
doc->addUpdate(FieldUpdate(doc->getType().getField("hstringval"))
- .addUpdate(std::make_unique<AssignValueUpdate>(StringFieldValue(hstr))));
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<StringFieldValue>(hstr))));
return doc;
}
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index 93ab1c370c5..27a9791b95c 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -120,13 +120,13 @@ TEST(DocumentUpdateTest, testSimpleUsage)
// Test that primitive value updates can be serialized
testRoundtripSerialize(ClearValueUpdate(), *DataType::INT);
- testRoundtripSerialize(AssignValueUpdate(IntFieldValue(1)), *DataType::INT);
+ testRoundtripSerialize(AssignValueUpdate(std::make_unique<IntFieldValue>(1)), *DataType::INT);
testRoundtripSerialize(ArithmeticValueUpdate(ArithmeticValueUpdate::Div, 4.3), *DataType::FLOAT);
- testRoundtripSerialize(AddValueUpdate(IntFieldValue(1), 4), *arrayType);
- testRoundtripSerialize(RemoveValueUpdate(IntFieldValue(1)), *arrayType);
+ testRoundtripSerialize(AddValueUpdate(std::make_unique<IntFieldValue>(1), 4), *arrayType);
+ testRoundtripSerialize(RemoveValueUpdate(std::make_unique<IntFieldValue>(1)), *arrayType);
FieldUpdate fieldUpdate(docType->getField("intf"));
- fieldUpdate.addUpdate(std::make_unique<AssignValueUpdate>(IntFieldValue(1)));
+ fieldUpdate.addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<IntFieldValue>(1)));
nbostream stream = serialize(fieldUpdate);
FieldUpdate fieldUpdateCopy(repo, *docType, stream);
EXPECT_EQ(fieldUpdate, fieldUpdateCopy);
@@ -158,7 +158,7 @@ TEST(DocumentUpdateTest, testSimpleUsage)
{
Document updated(doc);
DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1"));
- upd.addUpdate(FieldUpdate(docType->getField("intf")).addUpdate(std::make_unique<AssignValueUpdate>(IntFieldValue(15))));
+ upd.addUpdate(FieldUpdate(docType->getField("intf")).addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<IntFieldValue>(15))));
upd.applyTo(updated);
EXPECT_NE(doc, updated);
EXPECT_EQ(15, updated.getValue("intf")->getAsInt());
@@ -174,7 +174,7 @@ TEST(DocumentUpdateTest, testSimpleUsage)
{
Document updated(doc);
DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1"));
- upd.addUpdate(FieldUpdate(docType->getField("intarr")).addUpdate(std::make_unique<AddValueUpdate>(IntFieldValue(4))));
+ upd.addUpdate(FieldUpdate(docType->getField("intarr")).addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<IntFieldValue>(4))));
upd.applyTo(updated);
EXPECT_NE(doc, updated);
std::unique_ptr<ArrayFieldValue> val(dynamic_cast<ArrayFieldValue*>(updated.getValue("intarr").release()));
@@ -184,7 +184,7 @@ TEST(DocumentUpdateTest, testSimpleUsage)
{
Document updated(doc);
DocumentUpdate upd(repo, *docType, DocumentId("id:ns:test::1"));
- upd.addUpdate(FieldUpdate(docType->getField("intarr")).addUpdate(std::make_unique<RemoveValueUpdate>(IntFieldValue(3))));
+ upd.addUpdate(FieldUpdate(docType->getField("intarr")).addUpdate(std::make_unique<RemoveValueUpdate>(std::make_unique<IntFieldValue>(3))));
upd.applyTo(updated);
EXPECT_NE(doc, updated);
std::unique_ptr<ArrayFieldValue> val(dynamic_cast<ArrayFieldValue*>(updated.getValue("intarr").release()));
@@ -227,7 +227,7 @@ TEST(DocumentUpdateTest, testUpdateApplySingleValue)
// Apply an update.
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
- .addUpdate(FieldUpdate(doc->getField("headerval")).addUpdate(std::make_unique<AssignValueUpdate>(IntFieldValue(9))))
+ .addUpdate(FieldUpdate(doc->getField("headerval")).addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<IntFieldValue>(9))))
.applyTo(*doc);
EXPECT_EQ(9, doc->getValue("headerval")->getAsInt());
}
@@ -240,12 +240,12 @@ TEST(DocumentUpdateTest, testUpdateArray)
EXPECT_EQ((document::FieldValue*)nullptr, doc->getValue(doc->getField("tags")).get());
// Assign array field.
- ArrayFieldValue myarray(doc->getType().getField("tags").getDataType());
- myarray.add(StringFieldValue("foo"));
- myarray.add(StringFieldValue("bar"));
+ auto myarray = std::make_unique<ArrayFieldValue>(doc->getType().getField("tags").getDataType());
+ myarray->add(StringFieldValue("foo"));
+ myarray->add(StringFieldValue("bar"));
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
- .addUpdate(FieldUpdate(doc->getField("tags")).addUpdate(std::make_unique<AssignValueUpdate>(myarray)))
+ .addUpdate(FieldUpdate(doc->getField("tags")).addUpdate(std::make_unique<AssignValueUpdate>(std::move(myarray))))
.applyTo(*doc);
auto fval1(doc->getAs<ArrayFieldValue>(doc->getField("tags")));
ASSERT_EQ((size_t) 2, fval1->size());
@@ -255,8 +255,8 @@ TEST(DocumentUpdateTest, testUpdateArray)
// Append array field
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(doc->getField("tags"))
- .addUpdate(std::make_unique<AddValueUpdate>(StringFieldValue("another")))
- .addUpdate(std::make_unique<AddValueUpdate>(StringFieldValue("tag"))))
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<StringFieldValue>("another")))
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<StringFieldValue>("tag"))))
.applyTo(*doc);
std::unique_ptr<ArrayFieldValue>
fval2(doc->getAs<ArrayFieldValue>(doc->getField("tags")));
@@ -270,15 +270,15 @@ TEST(DocumentUpdateTest, testUpdateArray)
ASSERT_THROW(
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(doc->getField("tags"))
- .addUpdate(std::make_unique<AssignValueUpdate>(StringFieldValue("THROW MEH!"))))
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<StringFieldValue>("THROW MEH!"))))
.applyTo(*doc),
std::exception) << "Expected exception when assigning a string value to an array field.";
// Remove array field.
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(doc->getField("tags"))
- .addUpdate(std::make_unique<RemoveValueUpdate>(StringFieldValue("foo")))
- .addUpdate(std::make_unique<RemoveValueUpdate>(StringFieldValue("tag"))))
+ .addUpdate(std::make_unique<RemoveValueUpdate>(std::make_unique<StringFieldValue>("foo")))
+ .addUpdate(std::make_unique<RemoveValueUpdate>(std::make_unique<StringFieldValue>("tag"))))
.applyTo(*doc);
auto fval3(doc->getAs<ArrayFieldValue>(doc->getField("tags")));
ASSERT_EQ((size_t) 2, fval3->size());
@@ -286,27 +286,27 @@ TEST(DocumentUpdateTest, testUpdateArray)
EXPECT_EQ(std::string("another"), std::string((*fval3)[1].getAsString()));
// Remove array from array.
- ArrayFieldValue myarray2(doc->getType().getField("tags").getDataType());
- myarray2.add(StringFieldValue("foo"));
- myarray2.add(StringFieldValue("bar"));
+ auto myarray2 = std::make_unique<ArrayFieldValue>(doc->getType().getField("tags").getDataType());
+ myarray2->add(StringFieldValue("foo"));
+ myarray2->add(StringFieldValue("bar"));
ASSERT_THROW(
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(doc->getField("tags"))
- .addUpdate(std::make_unique<RemoveValueUpdate>(myarray2)))
+ .addUpdate(std::make_unique<RemoveValueUpdate>(std::move(myarray2))))
.applyTo(*doc),
std::exception) << "Expected exception when removing an array from a string array.";
}
std::unique_ptr<ValueUpdate>
createAddUpdate(vespalib::stringref key, int weight) {
- auto upd = std::make_unique<AddValueUpdate>(StringFieldValue(key));
+ auto upd = std::make_unique<AddValueUpdate>(std::make_unique<StringFieldValue>(key));
upd->setWeight(weight);
return upd;
}
std::unique_ptr<ValueUpdate>
createAddUpdate(int key, int weight) {
- auto upd = std::make_unique<AddValueUpdate>(IntFieldValue(key));
+ auto upd = std::make_unique<AddValueUpdate>(std::make_unique<IntFieldValue>(key));
upd->setWeight(weight);
return upd;
}
@@ -320,11 +320,11 @@ TEST(DocumentUpdateTest, testUpdateWeightedSet)
EXPECT_EQ((FieldValue*) 0, doc->getValue(field).get());
// Assign weightedset field
- WeightedSetFieldValue wset(field.getDataType());
- wset.add(StringFieldValue("foo"), 3);
- wset.add(StringFieldValue("bar"), 14);
+ auto wset =std::make_unique<WeightedSetFieldValue>(field.getDataType());
+ wset->add(StringFieldValue("foo"), 3);
+ wset->add(StringFieldValue("bar"), 14);
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
- .addUpdate(FieldUpdate(field).addUpdate(std::make_unique<AssignValueUpdate>(wset)))
+ .addUpdate(FieldUpdate(field).addUpdate(std::make_unique<AssignValueUpdate>(std::move(wset))))
.applyTo(*doc);
auto fval1(doc->getAs<WeightedSetFieldValue>(field));
ASSERT_EQ((size_t) 2, fval1->size());
@@ -336,12 +336,12 @@ TEST(DocumentUpdateTest, testUpdateWeightedSet)
EXPECT_EQ(14, fval1->get(StringFieldValue("bar"), 0));
// Do a second assign
- WeightedSetFieldValue wset2(field.getDataType());
- wset2.add(StringFieldValue("foo"), 16);
- wset2.add(StringFieldValue("bar"), 24);
+ auto wset2 = std::make_unique<WeightedSetFieldValue>(field.getDataType());
+ wset2->add(StringFieldValue("foo"), 16);
+ wset2->add(StringFieldValue("bar"), 24);
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(field)
- .addUpdate(std::make_unique<AssignValueUpdate>(wset2)))
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::move(wset2))))
.applyTo(*doc);
auto fval2(doc->getAs<WeightedSetFieldValue>(field));
ASSERT_EQ((size_t) 2, fval2->size());
@@ -371,8 +371,8 @@ TEST(DocumentUpdateTest, testUpdateWeightedSet)
// Remove weighted field
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(field)
- .addUpdate(std::make_unique<RemoveValueUpdate>(StringFieldValue("foo")))
- .addUpdate(std::make_unique<RemoveValueUpdate>(StringFieldValue("too"))))
+ .addUpdate(std::make_unique<RemoveValueUpdate>(std::make_unique<StringFieldValue>("foo")))
+ .addUpdate(std::make_unique<RemoveValueUpdate>(std::make_unique<StringFieldValue>("too"))))
.applyTo(*doc);
auto fval4(doc->getAs<WeightedSetFieldValue>(field));
ASSERT_EQ((size_t) 1, fval4->size());
@@ -419,7 +419,7 @@ WeightedSetAutoCreateFixture::WeightedSetAutoCreateFixture()
update(repo, *docType, DocumentId("id:ns:test::1"))
{
update.addUpdate(FieldUpdate(field)
- .addUpdate(std::make_unique<MapValueUpdate>(StringFieldValue("foo"),
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<StringFieldValue>("foo"),
std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 1))));
}
} // anon ns
@@ -457,7 +457,7 @@ TEST(DocumentUpdateTest, testIncrementWithZeroResultWeightIsRemoved)
{
WeightedSetAutoCreateFixture fixture;
fixture.update.addUpdate(FieldUpdate(fixture.field)
- .addUpdate(std::make_unique<MapValueUpdate>(StringFieldValue("baz"),
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<StringFieldValue>("baz"),
std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 0))));
fixture.applyUpdateToDocument();
@@ -539,19 +539,19 @@ TEST(DocumentUpdateTest, testGenerateSerializedFile)
const DocumentType *type(repo.getDocumentType("serializetest"));
DocumentUpdate upd(repo, *type, DocumentId("id:ns:serializetest::update"));
upd.addUpdate(FieldUpdate(type->getField("intfield"))
- .addUpdate(std::make_unique<AssignValueUpdate>(IntFieldValue(4))));
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<IntFieldValue>(4))));
upd.addUpdate(FieldUpdate(type->getField("floatfield"))
- .addUpdate(std::make_unique<AssignValueUpdate>(FloatFieldValue(1.00f))));
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<FloatFieldValue>(1.00f))));
upd.addUpdate(FieldUpdate(type->getField("arrayoffloatfield"))
- .addUpdate(std::make_unique<AddValueUpdate>(FloatFieldValue(5.00f)))
- .addUpdate(std::make_unique<AddValueUpdate>(FloatFieldValue(4.23f)))
- .addUpdate(std::make_unique<AddValueUpdate>(FloatFieldValue(-1.00f))));
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<FloatFieldValue>(5.00f)))
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<FloatFieldValue>(4.23f)))
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<FloatFieldValue>(-1.00f))));
upd.addUpdate(FieldUpdate(type->getField("intfield"))
.addUpdate(std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 3)));
upd.addUpdate(FieldUpdate(type->getField("wsfield"))
- .addUpdate(std::make_unique<MapValueUpdate>(StringFieldValue("foo"),
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<StringFieldValue>("foo"),
std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 2)))
- .addUpdate(std::make_unique<MapValueUpdate>(StringFieldValue("foo"),
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<StringFieldValue>("foo"),
std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Mul, 2))));
nbostream buf(serializeHEAD(upd));
writeBufferToFile(buf, "data/serializeupdatecpp.dat");
@@ -569,7 +569,7 @@ TEST(DocumentUpdateTest, testSetBadFieldTypes)
DocumentUpdate update(docMan.getTypeRepo(), *doc->getDataType(), doc->getId());
ASSERT_THROW(
update.addUpdate(FieldUpdate(doc->getField("headerval"))
- .addUpdate(std::make_unique<AssignValueUpdate>(FloatFieldValue(4.00f)))),
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<FloatFieldValue>(4.00f)))),
std::exception) << "Expected exception when adding a float to an int field.";
update.applyTo(*doc);
@@ -604,7 +604,7 @@ TEST(DocumentUpdateTest, testUpdateApplyNoArrayValues)
// Assign array field with no array values = empty array
DocumentUpdate update(docMan.getTypeRepo(), *doc->getDataType(), doc->getId());
update.addUpdate(FieldUpdate(field)
- .addUpdate(std::make_unique<AssignValueUpdate>(ArrayFieldValue(field.getDataType()))));
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<ArrayFieldValue>(field.getDataType()))));
update.applyTo(*doc);
@@ -624,7 +624,7 @@ TEST(DocumentUpdateTest, testUpdateArrayEmptyParamValue)
// Assign array field with no array values = empty array.
DocumentUpdate update(docMan.getTypeRepo(), *doc->getDataType(), doc->getId());
- update.addUpdate(FieldUpdate(field).addUpdate(std::make_unique<AssignValueUpdate>(ArrayFieldValue(field.getDataType()))));
+ update.addUpdate(FieldUpdate(field).addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<ArrayFieldValue>(field.getDataType()))));
update.applyTo(*doc);
// Verify that the field was set in the document.
@@ -652,7 +652,7 @@ TEST(DocumentUpdateTest, testUpdateWeightedSetEmptyParamValue)
// Assign weighted set with no items = empty set.
DocumentUpdate update(docMan.getTypeRepo(), *doc->getDataType(), doc->getId());
- update.addUpdate(FieldUpdate(field).addUpdate(std::make_unique<AssignValueUpdate>(WeightedSetFieldValue(field.getDataType()))));
+ update.addUpdate(FieldUpdate(field).addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<WeightedSetFieldValue>(field.getDataType()))));
update.applyTo(*doc);
// Verify that the field was set in the document.
@@ -682,8 +682,8 @@ TEST(DocumentUpdateTest, testUpdateArrayWrongSubtype)
DocumentUpdate update(docMan.getTypeRepo(), *doc->getDataType(), doc->getId());
ASSERT_THROW(
update.addUpdate(FieldUpdate(field)
- .addUpdate(std::make_unique<AddValueUpdate>(IntFieldValue(123)))
- .addUpdate(std::make_unique<AddValueUpdate>(IntFieldValue(456)))),
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<IntFieldValue>(123)))
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<IntFieldValue>(456)))),
std::exception) << "Expected exception when adding wrong type.";
// Apply update
@@ -732,7 +732,7 @@ TEST(DocumentUpdateTest, testMapValueUpdate)
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(field1)
- .addUpdate(std::make_unique<MapValueUpdate>(StringFieldValue("banana"),
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<StringFieldValue>("banana"),
std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 1.0))))
.applyTo(*doc);
std::unique_ptr<WeightedSetFieldValue> fv1 =
@@ -741,7 +741,7 @@ TEST(DocumentUpdateTest, testMapValueUpdate)
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(field2)
- .addUpdate(std::make_unique<MapValueUpdate>(StringFieldValue("banana"),
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<StringFieldValue>("banana"),
std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 1.0))))
.applyTo(*doc);
auto fv2 = doc->getAs<WeightedSetFieldValue>(field2);
@@ -770,7 +770,7 @@ TEST(DocumentUpdateTest, testMapValueUpdate)
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(field1)
- .addUpdate(std::make_unique<MapValueUpdate>(StringFieldValue("apple"),
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<StringFieldValue>("apple"),
std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Sub, 1.0))))
.applyTo(*doc);
@@ -780,7 +780,7 @@ TEST(DocumentUpdateTest, testMapValueUpdate)
DocumentUpdate(docMan.getTypeRepo(), *doc->getDataType(), doc->getId())
.addUpdate(FieldUpdate(field2)
- .addUpdate(std::make_unique<MapValueUpdate>(StringFieldValue("apple"),
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<StringFieldValue>("apple"),
std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Sub, 1.0))))
.applyTo(*doc);
@@ -940,10 +940,9 @@ struct TensorUpdateFixture {
TEST(DocumentUpdateTest, tensor_assign_update_can_be_applied)
{
TensorUpdateFixture f;
- auto newTensor = f.makeBaselineTensor();
- f.applyUpdate(std::make_unique<AssignValueUpdate>(*newTensor));
+ f.applyUpdate(std::make_unique<AssignValueUpdate>(f.makeBaselineTensor()));
f.assertDocumentUpdated();
- f.assertTensor(*newTensor);
+ f.assertTensor(*f.makeBaselineTensor());
}
TEST(DocumentUpdateTest, tensor_clear_update_can_be_applied)
@@ -1032,7 +1031,7 @@ TEST(DocumentUpdateTest, tensor_modify_update_can_be_applied_to_nonexisting_tens
TEST(DocumentUpdateTest, tensor_assign_update_can_be_roundtrip_serialized)
{
TensorUpdateFixture f;
- f.assertRoundtripSerialize(AssignValueUpdate(*f.makeBaselineTensor()));
+ f.assertRoundtripSerialize(AssignValueUpdate(f.makeBaselineTensor()));
}
TEST(DocumentUpdateTest, tensor_add_update_can_be_roundtrip_serialized)
@@ -1162,7 +1161,7 @@ struct TensorUpdateSerializeFixture {
(*repo, docType, DocumentId("id:test:test::0"));
result->addUpdate(FieldUpdate(getField("sparse_tensor"))
- .addUpdate(std::make_unique<AssignValueUpdate>(*makeTensor()))
+ .addUpdate(std::make_unique<AssignValueUpdate>(makeTensor()))
.addUpdate(std::make_unique<TensorAddUpdate>(makeTensor()))
.addUpdate(std::make_unique<TensorRemoveUpdate>(makeTensor())));
result->addUpdate(FieldUpdate(getField("dense_tensor"))
@@ -1250,7 +1249,7 @@ CreateIfNonExistentFixture::CreateIfNonExistentFixture()
update(std::make_unique<DocumentUpdate>(docMan.getTypeRepo(), *document->getDataType(), document->getId()))
{
update->addUpdate(FieldUpdate(document->getField("headerval"))
- .addUpdate(std::make_unique<AssignValueUpdate>(IntFieldValue(1))));
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<IntFieldValue>(1))));
update->setCreateIfNonExistent(true);
}
@@ -1282,8 +1281,8 @@ ArrayUpdateFixture::ArrayUpdateFixture()
{
update = std::make_unique<DocumentUpdate>(doc_man.getTypeRepo(), *doc->getDataType(), doc->getId());
update->addUpdate(FieldUpdate(array_field)
- .addUpdate(std::make_unique<MapValueUpdate>(IntFieldValue(1),
- std::make_unique<AssignValueUpdate>(StringFieldValue("bar")))));
+ .addUpdate(std::make_unique<MapValueUpdate>(std::make_unique<IntFieldValue>(1),
+ std::make_unique<AssignValueUpdate>(std::make_unique<StringFieldValue>("bar")))));
}
ArrayUpdateFixture::~ArrayUpdateFixture() = default;
diff --git a/document/src/tests/feed_reject_helper_test.cpp b/document/src/tests/feed_reject_helper_test.cpp
index 6649c9c0208..278e89b15a3 100644
--- a/document/src/tests/feed_reject_helper_test.cpp
+++ b/document/src/tests/feed_reject_helper_test.cpp
@@ -53,22 +53,22 @@ TEST(DocumentRejectTest, requireThatFixedSizeFieldValuesAreDetected) {
TEST(DocumentRejectTest, requireThatClearRemoveTensorRemoveAndArtithmeticUpdatesIgnoreFeedRejection) {
EXPECT_FALSE(FeedRejectHelper::mustReject(ClearValueUpdate()));
- EXPECT_FALSE(FeedRejectHelper::mustReject(RemoveValueUpdate(StringFieldValue())));
+ EXPECT_FALSE(FeedRejectHelper::mustReject(RemoveValueUpdate(std::make_unique<StringFieldValue>())));
EXPECT_FALSE(FeedRejectHelper::mustReject(ArithmeticValueUpdate(ArithmeticValueUpdate::Add, 5.0)));
EXPECT_FALSE(FeedRejectHelper::mustReject(TensorRemoveUpdate(std::make_unique<TensorFieldValue>())));
}
TEST(DocumentRejectTest, requireThatAddMapTensorModifyAndTensorAddUpdatesWillBeRejected) {
- EXPECT_TRUE(FeedRejectHelper::mustReject(AddValueUpdate(IntFieldValue())));
- EXPECT_TRUE(FeedRejectHelper::mustReject(MapValueUpdate(IntFieldValue(), std::make_unique<ClearValueUpdate>())));
+ EXPECT_TRUE(FeedRejectHelper::mustReject(AddValueUpdate(std::make_unique<IntFieldValue>())));
+ EXPECT_TRUE(FeedRejectHelper::mustReject(MapValueUpdate(std::make_unique<IntFieldValue>(), std::make_unique<ClearValueUpdate>())));
EXPECT_TRUE(FeedRejectHelper::mustReject(TensorModifyUpdate(TensorModifyUpdate::Operation::REPLACE,
std::make_unique<TensorFieldValue>())));
EXPECT_TRUE(FeedRejectHelper::mustReject(TensorAddUpdate(std::make_unique<TensorFieldValue>())));
}
TEST(DocumentRejectTest, requireThatAssignUpdatesWillBeRejectedBasedOnTheirContent) {
- EXPECT_FALSE(FeedRejectHelper::mustReject(AssignValueUpdate(IntFieldValue())));
- EXPECT_TRUE(FeedRejectHelper::mustReject(AssignValueUpdate(StringFieldValue())));
+ EXPECT_FALSE(FeedRejectHelper::mustReject(AssignValueUpdate(std::make_unique<IntFieldValue>())));
+ EXPECT_TRUE(FeedRejectHelper::mustReject(AssignValueUpdate(std::make_unique<StringFieldValue>())));
}
}
diff --git a/document/src/tests/testxml.cpp b/document/src/tests/testxml.cpp
index 978ab572214..998d41480f3 100644
--- a/document/src/tests/testxml.cpp
+++ b/document/src/tests/testxml.cpp
@@ -60,16 +60,16 @@ createTestDocumentUpdate(const DocumentTypeRepo& repo)
auto up = std::make_unique<DocumentUpdate>(repo, *type, id);
up->addUpdate(FieldUpdate(type->getField("intattr"))
- .addUpdate(std::make_unique<AssignValueUpdate>(IntFieldValue(7))));
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<IntFieldValue>(7))));
up->addUpdate(FieldUpdate(type->getField("stringattr"))
- .addUpdate(std::make_unique<AssignValueUpdate>(StringFieldValue("New value"))));
+ .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<StringFieldValue>("New value"))));
up->addUpdate(FieldUpdate(type->getField("arrayattr"))
- .addUpdate(std::make_unique<AddValueUpdate>(IntFieldValue(123)))
- .addUpdate(std::make_unique<AddValueUpdate>(IntFieldValue(456))));
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<IntFieldValue>(123)))
+ .addUpdate(std::make_unique<AddValueUpdate>(std::make_unique<IntFieldValue>(456))));
up->addUpdate(FieldUpdate(type->getField("arrayattr"))
- .addUpdate(std::make_unique<RemoveValueUpdate>(IntFieldValue(123)))
- .addUpdate(std::make_unique<RemoveValueUpdate>(IntFieldValue(456)))
- .addUpdate(std::make_unique<RemoveValueUpdate>(IntFieldValue(789))));
+ .addUpdate(std::make_unique<RemoveValueUpdate>(std::make_unique<IntFieldValue>(123)))
+ .addUpdate(std::make_unique<RemoveValueUpdate>(std::make_unique<IntFieldValue>(456)))
+ .addUpdate(std::make_unique<RemoveValueUpdate>(std::make_unique<IntFieldValue>(789))));
return up;
}