diff options
Diffstat (limited to 'searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp')
-rw-r--r-- | searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp b/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp index 3c157221e60..4c06feb6ae7 100644 --- a/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp +++ b/searchcore/src/tests/proton/matching/constant_value_repo/constant_value_repo_test.cpp @@ -2,7 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/searchcore/proton/matching/ranking_assets_repo.h> +#include <vespa/searchcore/proton/matching/constant_value_repo.h> #include <vespa/eval/eval/value_cache/constant_value.h> using namespace proton::matching; @@ -14,9 +14,9 @@ private: ValueType _type; public: - explicit DoubleConstantValue(double value_) : _value(value_), _type(ValueType::double_type()) {} - const ValueType &type() const override { return _type; } - const Value &value() const override { return _value; } + DoubleConstantValue(double value_) : _value(value_), _type(ValueType::double_type()) {} + virtual const ValueType &type() const override { return _type; } + virtual const Value &value() const override { return _value; } }; class MyConstantValueFactory : public ConstantValueFactory { @@ -30,7 +30,7 @@ public: void add(const vespalib::string &path, const vespalib::string &type, double value) { _map.insert(std::make_pair(std::make_pair(path, type), value)); } - ConstantValue::UP create(const vespalib::string &path, const vespalib::string &type) const override { + virtual ConstantValue::UP create(const vespalib::string &path, const vespalib::string &type) const override { auto itr = _map.find(std::make_pair(path, type)); if (itr != _map.end()) { return std::make_unique<DoubleConstantValue>(itr->second); @@ -41,16 +41,14 @@ public: struct Fixture { MyConstantValueFactory factory; - RankingAssetsRepo repo; + ConstantValueRepo repo; Fixture() : factory(), repo(factory) { factory.add("path_1", "double", 3); factory.add("path_2", "double", 5); - RankingConstants::Vector constants; - constants.emplace_back("foo", "double", "path_1"); - constants.emplace_back("bar", "double", "path_3"); - repo.reconfigure(std::make_shared<RankingConstants>(constants),{}, {}); + repo.reconfigure(RankingConstants({{"foo", "double", "path_1"}, + {"bar", "double", "path_3"}})); } }; @@ -71,10 +69,8 @@ TEST_F("require that non-existing constant value in factory returns bad constant TEST_F("require that reconfigure replaces existing constant values in repo", Fixture) { - RankingConstants::Vector constants; - constants.emplace_back("bar", "double", "path_3"); - constants.emplace_back("baz", "double", "path_2"); - f.repo.reconfigure(std::make_shared<RankingConstants>(constants), {}, {}); + f.repo.reconfigure(RankingConstants({{"bar", "double", "path_3"}, + {"baz", "double", "path_2"}})); f.factory.add("path_3", "double", 7); EXPECT_TRUE(f.repo.getConstant("foo").get() == nullptr); EXPECT_EQUAL(7, f.repo.getConstant("bar")->value().as_double()); |