aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-07-06 14:30:15 +0200
committerGitHub <noreply@github.com>2023-07-06 14:30:15 +0200
commit37da17032fc5ec53ca1407a8986f20864c249706 (patch)
tree9b6bca3a3ea34521fe8bad50aee65fc454a9daa8 /searchlib
parentbd7356f18947ba1b08ef43e82e74018e664c0893 (diff)
parenta0d42a4a6b3cb44ade42d9d46f88d0ce8ad15e1e (diff)
Merge pull request #27653 from vespa-engine/balder/reduce-copy-paste-mutate
- Use a single templated fixture to avoid copy-paste errors when exte…
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp37
1 files changed, 13 insertions, 24 deletions
diff --git a/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp b/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
index c864877aec2..5518f47ef5d 100644
--- a/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
+++ b/searchlib/src/tests/attribute/document_weight_iterator/document_weight_iterator_test.cpp
@@ -62,39 +62,28 @@ void populate_string(AttributeVector::SP attr_ptr) {
set_doc(attr, 7, "foo", 10);
}
-template<CollectionType::Type CT>
-struct LongFixture {
+template<BasicType::Type BT, CollectionType::Type CT>
+struct Fixture {
AttributeVector::SP attr;
const IDocumentWeightAttribute *api;
- LongFixture()
- : attr(make_attribute(BasicType::INT64, CollectionType::WSET, true)),
+ Fixture()
+ : attr(make_attribute(BT, CT, true)),
api(attr->asDocumentWeightAttribute())
{
ASSERT_TRUE(api != nullptr);
add_docs(attr);
- populate_long(attr);
- }
-};
-
-using LongWsetFixture = LongFixture<CollectionType::WSET>;
-using LongArrayFixture = LongFixture<CollectionType::ARRAY>;
-
-template<CollectionType::Type CT>
-struct StringFixture {
- AttributeVector::SP attr;
- const IDocumentWeightAttribute *api;
- StringFixture()
- : attr(make_attribute(BasicType::STRING, CT, true)),
- api(attr->asDocumentWeightAttribute())
- {
- ASSERT_TRUE(api != nullptr);
- add_docs(attr);
- populate_string(attr);
+ if (BT == BasicType::STRING) {
+ populate_string(attr);
+ } else {
+ populate_long(attr);
+ }
}
};
-using StringWsetFixture = StringFixture<CollectionType::WSET>;
-using StringArrayFixture = StringFixture<CollectionType::ARRAY>;
+using LongWsetFixture = Fixture<BasicType::INT64, CollectionType::WSET>;
+using LongArrayFixture = Fixture<BasicType::INT64, CollectionType::ARRAY>;
+using StringWsetFixture = Fixture<BasicType::STRING, CollectionType::WSET>;
+using StringArrayFixture = Fixture<BasicType::STRING, CollectionType::ARRAY>;
TEST("require that appropriate attributes support the document weight attribute interface") {
EXPECT_TRUE(make_attribute(BasicType::INT32, CollectionType::WSET, true)->asDocumentWeightAttribute() != nullptr);