diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-28 11:43:52 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-28 14:49:19 +0000 |
commit | 1cd2c6a3ba9e392c00b91bfe3cf1215a80c6679f (patch) | |
tree | 4cbcddcf8922d4a3447d0806bfab26d935e8ccbe /searchcore/src/tests | |
parent | 8976efd142145482d61d83755db2fab0a8b626a6 (diff) |
Remove copy constructors.
Diffstat (limited to 'searchcore/src/tests')
5 files changed, 68 insertions, 93 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index 51bc60d3783..de6b923bdc1 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -526,9 +526,8 @@ TEST_F(AttributeWriterTest, handles_predicate_update) const document::DocumentType &dt(idb.getDocumentType()); DocumentUpdate upd(*idb.getDocumentTypeRepo(), dt, DocumentId("id:ns:searchdocument::1")); - PredicateFieldValue new_value(builder.feature("foo").value("bar").build()); upd.addUpdate(FieldUpdate(upd.getType().getField("a1")) - .addUpdate(std::make_unique<AssignValueUpdate>(new_value))); + .addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<PredicateFieldValue>(builder.feature("foo").value("bar").build())))); PredicateIndex &index = static_cast<PredicateAttribute &>(*a1).getIndex(); EXPECT_EQ(1u, index.getZeroConstraintDocs().size()); @@ -726,10 +725,10 @@ TEST_F(AttributeWriterTest, handles_tensor_assign_update) auto new_tensor = make_tensor(TensorSpec(sparse_tensor) .add({{"x", "8"}, {"y", "9"}}, 11)); TensorDataType xySparseTensorDataType(vespalib::eval::ValueType::from_spec(sparse_tensor)); - TensorFieldValue new_value(xySparseTensorDataType); - new_value = SimpleValue::from_value(*new_tensor); + auto new_value = std::make_unique<TensorFieldValue>(xySparseTensorDataType); + *new_value = SimpleValue::from_value(*new_tensor); upd.addUpdate(FieldUpdate(upd.getType().getField("a1")) - .addUpdate(std::make_unique<AssignValueUpdate>(new_value))); + .addUpdate(std::make_unique<AssignValueUpdate>(std::move(new_value)))); DummyFieldUpdateCallback onUpdate; update(2, upd, 1, onUpdate); EXPECT_EQ(2u, a1->getNumDocs()); @@ -936,9 +935,9 @@ public: builder.getDocumentType(), DocumentId(doc_id)); TensorDataType tensor_type(vespalib::eval::ValueType::from_spec(dense_tensor)); - TensorFieldValue tensor_value(tensor_type); - tensor_value= SimpleValue::from_value(*tensor); - upd->addUpdate(FieldUpdate(upd->getType().getField("a1")).addUpdate(std::make_unique<AssignValueUpdate>(tensor_value))); + auto tensor_value = std::make_unique<TensorFieldValue>(tensor_type); + *tensor_value = SimpleValue::from_value(*tensor); + upd->addUpdate(FieldUpdate(upd->getType().getField("a1")).addUpdate(std::make_unique<AssignValueUpdate>(std::move(tensor_value)))); return upd; } void expect_shared_executor_tasks(size_t exp_accepted_tasks) { diff --git a/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp b/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp index 20584a2a1fb..d2897216ea2 100644 --- a/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp +++ b/searchcore/src/tests/proton/common/attribute_updater/attribute_updater_test.cpp @@ -104,21 +104,21 @@ struct Fixture { vec.commit(); } - void applyArrayUpdates(AttributeVector & vec, const FieldValue & assign, - const FieldValue & first, const FieldValue & second) { - applyValueUpdate(vec, 0, std::make_unique<AssignValueUpdate>(assign)); - applyValueUpdate(vec, 1, std::make_unique<AddValueUpdate>(second)); - applyValueUpdate(vec, 2, std::make_unique<RemoveValueUpdate>(first)); + void applyArrayUpdates(AttributeVector & vec, std::unique_ptr<FieldValue> assign, + std::unique_ptr<FieldValue> first, std::unique_ptr<FieldValue> second) { + applyValueUpdate(vec, 0, std::make_unique<AssignValueUpdate>(std::move(assign))); + applyValueUpdate(vec, 1, std::make_unique<AddValueUpdate>(std::move(second))); + applyValueUpdate(vec, 2, std::make_unique<RemoveValueUpdate>(std::move(first))); applyValueUpdate(vec, 3, std::make_unique<ClearValueUpdate>()); } - void applyWeightedSetUpdates(AttributeVector & vec, const FieldValue & assign, - const FieldValue & first, const FieldValue & second) { - applyValueUpdate(vec, 0, std::make_unique<AssignValueUpdate>(assign)); - applyValueUpdate(vec, 1, std::make_unique<AddValueUpdate>(second, 20)); - applyValueUpdate(vec, 2, std::make_unique<RemoveValueUpdate>(first)); + void applyWeightedSetUpdates(AttributeVector & vec, std::unique_ptr<FieldValue> assign, + std::unique_ptr<FieldValue> first, std::unique_ptr<FieldValue> copyOfFirst, std::unique_ptr<FieldValue> second) { + applyValueUpdate(vec, 0, std::make_unique<AssignValueUpdate>(std::move(assign))); + applyValueUpdate(vec, 1, std::make_unique<AddValueUpdate>(std::move(second), 20)); + applyValueUpdate(vec, 2, std::make_unique<RemoveValueUpdate>(std::move(first))); applyValueUpdate(vec, 3, std::make_unique<ClearValueUpdate>()); - applyValueUpdate(vec, 4, std::make_unique<MapValueUpdate>(first, std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 10))); + applyValueUpdate(vec, 4, std::make_unique<MapValueUpdate>(std::move(copyOfFirst), std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 10))); } }; @@ -203,10 +203,8 @@ TEST_F("require that single attributes are updated", Fixture) CollectionType ct(CollectionType::SINGLE); { BasicType bt(BasicType::INT32); - AttributePtr vec = create<int32_t, IntegerAttribute>(3, 32, 0, - "in1/int", - Config(bt, ct)); - f.applyValueUpdate(*vec, 0, std::make_unique<AssignValueUpdate>(IntFieldValue(64))); + AttributePtr vec = create<int32_t, IntegerAttribute>(3, 32, 0, "in1/int", Config(bt, ct)); + f.applyValueUpdate(*vec, 0, std::make_unique<AssignValueUpdate>(std::make_unique<IntFieldValue>(64))); f.applyValueUpdate(*vec, 1, std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 10)); f.applyValueUpdate(*vec, 2, std::make_unique<ClearValueUpdate>()); EXPECT_EQUAL(3u, vec->getNumDocs()); @@ -216,11 +214,8 @@ TEST_F("require that single attributes are updated", Fixture) } { BasicType bt(BasicType::FLOAT); - AttributePtr vec = create<float, FloatingPointAttribute>(3, 55.5f, 0, - "in1/float", - Config(bt, - ct)); - f.applyValueUpdate(*vec, 0, std::make_unique<AssignValueUpdate>(FloatFieldValue(77.7f))); + AttributePtr vec = create<float, FloatingPointAttribute>(3, 55.5f, 0, "in1/float",Config(bt, ct)); + f.applyValueUpdate(*vec, 0, std::make_unique<AssignValueUpdate>(std::make_unique<FloatFieldValue>(77.7f))); f.applyValueUpdate(*vec, 1, std::make_unique<ArithmeticValueUpdate>(ArithmeticValueUpdate::Add, 10)); f.applyValueUpdate(*vec, 2, std::make_unique<ClearValueUpdate>()); EXPECT_EQUAL(3u, vec->getNumDocs()); @@ -230,11 +225,8 @@ TEST_F("require that single attributes are updated", Fixture) } { BasicType bt(BasicType::STRING); - AttributePtr vec = create<std::string, StringAttribute>(3, "first", 0, - "in1/string", - Config(bt, - ct)); - f.applyValueUpdate(*vec, 0, std::make_unique<AssignValueUpdate>(StringFieldValue("second"))); + AttributePtr vec = create<std::string, StringAttribute>(3, "first", 0, "in1/string",Config(bt, ct)); + f.applyValueUpdate(*vec, 0, std::make_unique<AssignValueUpdate>(std::make_unique<StringFieldValue>("second"))); f.applyValueUpdate(*vec, 2, std::make_unique<ClearValueUpdate>()); EXPECT_EQUAL(3u, vec->getNumDocs()); EXPECT_TRUE(check(vec, 0, std::vector<WeightedString>{WeightedString("second")})); @@ -254,7 +246,7 @@ TEST_F("require that single attributes are updated", Fixture) asReferenceAttribute(*vec).update(docId, toGid(doc1)); } vec->commit(); - f.applyValueUpdate(*vec, 0, std::make_unique<AssignValueUpdate>(ReferenceFieldValue(dynamic_cast<const ReferenceDataType &>(f.docType->getField("ref").getDataType()), DocumentId(doc2)))); + f.applyValueUpdate(*vec, 0, std::make_unique<AssignValueUpdate>(std::make_unique<ReferenceFieldValue>(dynamic_cast<const ReferenceDataType &>(f.docType->getField("ref").getDataType()), DocumentId(doc2)))); f.applyValueUpdate(*vec, 2, std::make_unique<ClearValueUpdate>()); EXPECT_EQUAL(3u, vec->getNumDocs()); TEST_DO(assertRef(*vec, doc2, 0)); @@ -268,14 +260,12 @@ TEST_F("require that array attributes are updated", Fixture) CollectionType ct(CollectionType::ARRAY); { BasicType bt(BasicType::INT32); - AttributePtr vec = create<int32_t, IntegerAttribute>(5, 32, 1, - "in1/aint", - Config(bt, ct)); - IntFieldValue first(32); - IntFieldValue second(64); - ArrayFieldValue assign(f.docType->getField("aint").getDataType()); - assign.add(second); - f.applyArrayUpdates(*vec, assign, first, second); + AttributePtr vec = create<int32_t, IntegerAttribute>(5, 32, 1, "in1/aint", Config(bt, ct)); + auto first = std::make_unique<IntFieldValue>(32); + auto second = std::make_unique<IntFieldValue>(64); + auto assign = std::make_unique<ArrayFieldValue>(f.docType->getField("aint").getDataType()); + assign->add(*second); + f.applyArrayUpdates(*vec, std::move(assign), std::move(first), std::move(second)); EXPECT_EQUAL(5u, vec->getNumDocs()); EXPECT_TRUE(check(vec, 0, std::vector<WeightedInt>{WeightedInt(64)})); @@ -286,15 +276,12 @@ TEST_F("require that array attributes are updated", Fixture) } { BasicType bt(BasicType::FLOAT); - AttributePtr vec = create<float, FloatingPointAttribute>(5, 55.5f, 1, - "in1/afloat", - Config(bt, - ct)); - FloatFieldValue first(55.5f); - FloatFieldValue second(77.7f); - ArrayFieldValue assign(f.docType->getField("afloat").getDataType()); - assign.add(second); - f.applyArrayUpdates(*vec, assign, first, second); + AttributePtr vec = create<float, FloatingPointAttribute>(5, 55.5f, 1, "in1/afloat", Config(bt, ct)); + auto first = std::make_unique<FloatFieldValue>(55.5f); + auto second = std::make_unique<FloatFieldValue>(77.7f); + auto assign = std::make_unique<ArrayFieldValue>(f.docType->getField("afloat").getDataType()); + assign->add(*second); + f.applyArrayUpdates(*vec, std::move(assign), std::move(first), std::move(second)); EXPECT_EQUAL(5u, vec->getNumDocs()); EXPECT_TRUE(check(vec, 0, std::vector<WeightedFloat>{WeightedFloat(77.7f)})); @@ -305,14 +292,12 @@ TEST_F("require that array attributes are updated", Fixture) } { BasicType bt(BasicType::STRING); - AttributePtr vec = create<std::string, StringAttribute>(5, "first", 1, - "in1/astring", - Config(bt, ct)); - StringFieldValue first("first"); - StringFieldValue second("second"); - ArrayFieldValue assign(f.docType->getField("astring").getDataType()); - assign.add(second); - f.applyArrayUpdates(*vec, assign, first, second); + AttributePtr vec = create<std::string, StringAttribute>(5, "first", 1, "in1/astring", Config(bt, ct)); + auto first = std::make_unique<StringFieldValue>("first"); + auto second = std::make_unique<StringFieldValue>("second"); + auto assign = std::make_unique<ArrayFieldValue>(f.docType->getField("astring").getDataType()); + assign->add(*second); + f.applyArrayUpdates(*vec, std::move(assign), std::move(first), std::move(second)); EXPECT_EQUAL(5u, vec->getNumDocs()); EXPECT_TRUE(check(vec, 0, std::vector<WeightedString>{WeightedString("second")})); @@ -328,15 +313,13 @@ TEST_F("require that weighted set attributes are updated", Fixture) CollectionType ct(CollectionType::WSET); { BasicType bt(BasicType::INT32); - AttributePtr vec = create<int32_t, IntegerAttribute>(5, 32, 100, - "in1/wsint", - Config(bt, ct)); - IntFieldValue first(32); - IntFieldValue second(64); - WeightedSetFieldValue - assign(f.docType->getField("wsint").getDataType()); - assign.add(second, 20); - f.applyWeightedSetUpdates(*vec, assign, first, second); + AttributePtr vec = create<int32_t, IntegerAttribute>(5, 32, 100, "in1/wsint", Config(bt, ct)); + auto first = std::make_unique<IntFieldValue>(32); + auto copyOfFirst = std::make_unique<IntFieldValue>(32); + auto second = std::make_unique<IntFieldValue>(64); + auto assign = std::make_unique<WeightedSetFieldValue>(f.docType->getField("wsint").getDataType()); + assign->add(*second, 20); + f.applyWeightedSetUpdates(*vec, std::move(assign), std::move(first), std::move(copyOfFirst), std::move(second)); EXPECT_EQUAL(5u, vec->getNumDocs()); EXPECT_TRUE(check(vec, 0, std::vector<WeightedInt>{WeightedInt(64, 20)})); @@ -347,16 +330,13 @@ TEST_F("require that weighted set attributes are updated", Fixture) } { BasicType bt(BasicType::FLOAT); - AttributePtr vec = create<float, FloatingPointAttribute>(5, 55.5f, 100, - "in1/wsfloat", - Config(bt, - ct)); - FloatFieldValue first(55.5f); - FloatFieldValue second(77.7f); - WeightedSetFieldValue - assign(f.docType->getField("wsfloat").getDataType()); - assign.add(second, 20); - f.applyWeightedSetUpdates(*vec, assign, first, second); + AttributePtr vec = create<float, FloatingPointAttribute>(5, 55.5f, 100, "in1/wsfloat", Config(bt, ct)); + auto first = std::make_unique<FloatFieldValue>(55.5f); + auto copyOfFirst = std::make_unique<FloatFieldValue>(55.5f); + auto second = std::make_unique<FloatFieldValue>(77.7f); + auto assign = std::make_unique<WeightedSetFieldValue>(f.docType->getField("wsfloat").getDataType()); + assign->add(*second, 20); + f.applyWeightedSetUpdates(*vec, std::move(assign), std::move(first), std::move(copyOfFirst), std::move(second)); EXPECT_EQUAL(5u, vec->getNumDocs()); EXPECT_TRUE(check(vec, 0, std::vector<WeightedFloat>{WeightedFloat(77.7f, 20)})); @@ -367,17 +347,13 @@ TEST_F("require that weighted set attributes are updated", Fixture) } { BasicType bt(BasicType::STRING); - AttributePtr vec = create<std::string, StringAttribute>(5, "first", - 100, - "in1/wsstring", - Config(bt, - ct)); - StringFieldValue first("first"); - StringFieldValue second("second"); - WeightedSetFieldValue - assign(f.docType->getField("wsstring").getDataType()); - assign.add(second, 20); - f.applyWeightedSetUpdates(*vec, assign, first, second); + AttributePtr vec = create<std::string, StringAttribute>(5, "first", 100, "in1/wsstring", Config(bt, ct)); + auto first = std::make_unique<StringFieldValue>("first"); + auto copyOfFirst = std::make_unique<StringFieldValue>("first"); + auto second = std::make_unique<StringFieldValue>("second"); + auto assign = std::make_unique<WeightedSetFieldValue>(f.docType->getField("wsstring").getDataType()); + assign->add(*second, 20); + f.applyWeightedSetUpdates(*vec, std::move(assign), std::move(first), std::move(copyOfFirst), std::move(second)); EXPECT_EQUAL(5u, vec->getNumDocs()); EXPECT_TRUE(check(vec, 0, std::vector<WeightedString>{WeightedString("second", 20)})); diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 6cd92dea516..94595f0efc7 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -345,7 +345,7 @@ struct UpdateContext { } else { fieldValue->assign(document::StringFieldValue("new value")); } - update->addUpdate(document::FieldUpdate(field).addUpdate(std::make_unique<document::AssignValueUpdate>(*fieldValue))); + update->addUpdate(document::FieldUpdate(field).addUpdate(std::make_unique<document::AssignValueUpdate>(std::move(fieldValue)))); } }; @@ -774,7 +774,7 @@ TEST_F("require that all value updates will be inspected before rejected", Schem EXPECT_FALSE(FeedRejectHelper::mustReject(*docUpdate)); docUpdate->addUpdate(std::move(FieldUpdate(docType->getField("i1")).addUpdate(std::make_unique<ClearValueUpdate>()))); EXPECT_FALSE(FeedRejectHelper::mustReject(*docUpdate)); - docUpdate->addUpdate(std::move(FieldUpdate(docType->getField("i1")).addUpdate(std::make_unique<AssignValueUpdate>(StringFieldValue())))); + docUpdate->addUpdate(std::move(FieldUpdate(docType->getField("i1")).addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<StringFieldValue>())))); EXPECT_TRUE(FeedRejectHelper::mustReject(*docUpdate)); } diff --git a/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp b/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp index 40332157a8d..dea3a3e69a6 100644 --- a/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp +++ b/searchcore/src/tests/proton/feedoperation/feedoperation_test.cpp @@ -122,7 +122,7 @@ public: auto makeUpdate() { auto upd(std::make_shared<DocumentUpdate>(*_repo, _docType, docId)); upd->addUpdate(FieldUpdate(upd->getType().getField("string")). - addUpdate(std::make_unique<AssignValueUpdate>(StringFieldValue("newval")))); + addUpdate(std::make_unique<AssignValueUpdate>(std::make_unique<StringFieldValue>("newval")))); return upd; } auto makeDoc() { diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp index 7f35e05dfb6..6fb7a35fffe 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp @@ -521,7 +521,7 @@ TEST_F("require that update is rejected if resource limit is reached", SimpleFix document::Field field("string", 1, *document::DataType::STRING); type.addField(field); DocumentUpdate::SP upd = createUpd(type, docId1); - upd->addUpdate(std::move(document::FieldUpdate(field).addUpdate(std::make_unique<document::AssignValueUpdate>(document::StringFieldValue("new value"))))); + upd->addUpdate(std::move(document::FieldUpdate(field).addUpdate(std::make_unique<document::AssignValueUpdate>(std::make_unique<document::StringFieldValue>("new value"))))); EXPECT_EQUAL( Result(Result::ErrorType::RESOURCE_EXHAUSTED, |