diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-08-29 11:38:34 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-08-29 11:38:34 +0200 |
commit | bfeb39f0ad4a6b2c2b1d09757507c42ef78a1c60 (patch) | |
tree | a25a8936794a6c98c00eeabb7b669d97cfeec080 /searchsummary | |
parent | ee29a7aeb10021c55064f6c5268daefe23897f0d (diff) |
Reduce use of new in summary field converter unit test.
Diffstat (limited to 'searchsummary')
3 files changed, 23 insertions, 30 deletions
diff --git a/searchsummary/src/tests/docsummary/document_id_dfw/document_id_dfw_test.cpp b/searchsummary/src/tests/docsummary/document_id_dfw/document_id_dfw_test.cpp index 9143f17cb67..06a20563161 100644 --- a/searchsummary/src/tests/docsummary/document_id_dfw/document_id_dfw_test.cpp +++ b/searchsummary/src/tests/docsummary/document_id_dfw/document_id_dfw_test.cpp @@ -44,7 +44,7 @@ make_doc_type_repo() DocumenttypesConfigBuilderHelper builder; builder.document(doc_type_id, doc_type_name, Struct(header_name), Struct(body_name)); - return std::unique_ptr<const DocumentTypeRepo>(new DocumentTypeRepo(builder.config())); + return std::make_unique<const DocumentTypeRepo>(builder.config()); } class DocumentIdDFWTest : public ::testing::Test diff --git a/searchsummary/src/tests/docsummary/positionsdfw_test.cpp b/searchsummary/src/tests/docsummary/positionsdfw_test.cpp index 60584b26e31..09051e2e9c0 100644 --- a/searchsummary/src/tests/docsummary/positionsdfw_test.cpp +++ b/searchsummary/src/tests/docsummary/positionsdfw_test.cpp @@ -98,7 +98,7 @@ public: } IAttributeContext::UP createContext() const override { - return IAttributeContext::UP(new MyAttributeContext(_attr)); + return std::make_unique<MyAttributeContext>(_attr); } std::shared_ptr<attribute::ReadableAttributeVector> readable_attribute_vector(const string&) const override { diff --git a/searchsummary/src/tests/docsummary/summary_field_converter/summary_field_converter_test.cpp b/searchsummary/src/tests/docsummary/summary_field_converter/summary_field_converter_test.cpp index 06766ba370a..c6f310f2d53 100644 --- a/searchsummary/src/tests/docsummary/summary_field_converter/summary_field_converter_test.cpp +++ b/searchsummary/src/tests/docsummary/summary_field_converter/summary_field_converter_test.cpp @@ -242,7 +242,7 @@ DocumenttypesConfig getDocumenttypesConfig() { } Test::Test() : - _documentRepo(new DocumentTypeRepo(getDocumenttypesConfig())), + _documentRepo(std::make_unique<DocumentTypeRepo>(getDocumenttypesConfig())), _documentType(_documentRepo->getDocumentType("indexingdocument")), _fixedRepo(*_documentRepo, *_documentType) { @@ -285,8 +285,8 @@ Test::Main() } void Test::setUp() { - _schema.reset(new Schema); - _summarymap.reset(new SummarymapConfigBuilder); + _schema = std::make_unique<Schema>(); + _summarymap = std::make_unique<SummarymapConfigBuilder>(); } void Test::tearDown() { @@ -298,34 +298,26 @@ const DataType &Test::getDataType(const string &name) const { return *type; } -template <typename T> -std::unique_ptr<T> makeUP(T *p) { return std::unique_ptr<T>(p); } - StringFieldValue Test::makeAnnotatedString() { - SpanList *span_list = new SpanList; - SpanTree::UP tree(new SpanTree(SPANTREE_NAME, makeUP(span_list))); + auto span_list_up = std::make_unique<SpanList>(); + auto span_list = span_list_up.get(); + auto tree = std::make_unique<SpanTree>(SPANTREE_NAME, std::move(span_list_up)); // Annotations don't have to be added sequentially. - tree->annotate(span_list->add(makeUP(new Span(8, 3))), - makeUP(new Annotation(*TERM, - makeUP(new StringFieldValue( - "Annotation"))))); - tree->annotate(span_list->add(makeUP(new Span(0, 3))), *TERM); - tree->annotate(span_list->add(makeUP(new Span(4, 3))), *TERM); - tree->annotate(span_list->add(makeUP(new Span(4, 3))), - makeUP(new Annotation(*TERM, - makeUP(new StringFieldValue( - "Multiple"))))); - tree->annotate(span_list->add(makeUP(new Span(1, 2))), - makeUP(new Annotation(*TERM, - makeUP(new StringFieldValue( - "Overlap"))))); + tree->annotate(span_list->add(std::make_unique<Span>(8, 3)), + Annotation(*TERM, std::make_unique<StringFieldValue>("Annotation"))); + tree->annotate(span_list->add(std::make_unique<Span>(0, 3)), *TERM); + tree->annotate(span_list->add(std::make_unique<Span>(4, 3)), *TERM); + tree->annotate(span_list->add(std::make_unique<Span>(4, 3)), + Annotation(*TERM, std::make_unique<StringFieldValue>("Multiple"))); + tree->annotate(span_list->add(std::make_unique<Span>(1, 2)), + Annotation(*TERM, std::make_unique<StringFieldValue>("Overlap"))); StringFieldValue value("Foo Bar Baz"); setSpanTree(value, std::move(tree)); return value; } StringFieldValue Test::annotateTerm(const string &term) { - SpanTree::UP tree(new SpanTree(SPANTREE_NAME, makeUP(new Span(0, term.size())))); + auto tree = std::make_unique<SpanTree>(SPANTREE_NAME, std::make_unique<Span>(0, term.size())); tree->annotate(tree->getRoot(), *TERM); StringFieldValue value(term); setSpanTree(value, std::move(tree)); @@ -339,11 +331,12 @@ void Test::setSpanTree(StringFieldValue & value, SpanTree::UP tree) { } StringFieldValue Test::makeAnnotatedChineseString() { - SpanList *span_list = new SpanList; - SpanTree::UP tree(new SpanTree(SPANTREE_NAME, makeUP(span_list))); + auto span_list_up = std::make_unique<SpanList>(); + auto span_list = span_list_up.get(); + auto tree = std::make_unique<SpanTree>(SPANTREE_NAME, std::move(span_list_up)); // These chinese characters each use 3 bytes in their UTF8 encoding. - tree->annotate(span_list->add(makeUP(new Span(0, 15))), *TERM); - tree->annotate(span_list->add(makeUP(new Span(15, 9))), *TERM); + tree->annotate(span_list->add(std::make_unique<Span>(0, 15)), *TERM); + tree->annotate(span_list->add(std::make_unique<Span>(15, 9)), *TERM); StringFieldValue value("我就是那个大灰狼"); setSpanTree(value, std::move(tree)); return value; @@ -660,7 +653,7 @@ void Test::requireThatLinguisticsAnnotationUsesDefaultDataTypes() { void Test::requireThatPredicateIsPrinted() { - std::unique_ptr<Slime> input(new Slime()); + auto input = std::make_unique<Slime>(); Cursor &obj = input->setObject(); obj.setLong(Predicate::NODE_TYPE, Predicate::TYPE_FEATURE_SET); obj.setString(Predicate::KEY, "foo"); |