diff options
author | Haavard <havardpe@yahoo-inc.com> | 2017-08-15 09:14:01 +0000 |
---|---|---|
committer | Haavard <havardpe@yahoo-inc.com> | 2017-08-15 09:14:01 +0000 |
commit | a6aa304b212618d13edfeb21a09b24cffd04a6f8 (patch) | |
tree | a8fc97c169bf292a4d2f096f860a7da903b8464c /searchlib | |
parent | a0f228b232d8cd34f7c5ea24f9709b98984eb38f (diff) |
test that appropriate executor is created
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp b/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp index 98d72b7d3e2..1e6aa11a8ed 100644 --- a/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp +++ b/searchlib/src/tests/features/ranking_expression/ranking_expression_test.cpp @@ -7,6 +7,7 @@ #include <vespa/searchlib/features/rankingexpressionfeature.h> #include <vespa/searchlib/fef/test/dummy_dependency_handler.h> #include <vespa/searchlib/fef/test/indexenvironment.h> +#include <vespa/searchlib/fef/test/queryenvironment.h> using namespace search::features; using namespace search::features::rankingexpression; @@ -16,12 +17,16 @@ using namespace vespalib::eval; using TypeMap = std::map<vespalib::string,vespalib::string>; +struct DummyExecutor : FeatureExecutor { + void execute(uint32_t) override {} +}; + struct DummyExpression : IntrinsicExpression { FeatureType type; DummyExpression(const FeatureType &type_in) : type(type_in) {} FeatureType result_type() const override { return type; } - FeatureExecutor &create_executor(const QueryEnv &, vespalib::Stash &) const override { - abort(); + FeatureExecutor &create_executor(const QueryEnv &, vespalib::Stash &stash) const override { + return stash.create<DummyExecutor>(); } }; @@ -53,7 +58,9 @@ ExpressionReplacer::SP make_replacer() { } struct SetupResult { + vespalib::Stash stash; IndexEnvironment index_env; + QueryEnvironment query_env; RankingExpressionBlueprint rank; DummyDependencyHandler deps; bool setup_ok; @@ -63,7 +70,7 @@ struct SetupResult { SetupResult::SetupResult(const TypeMap &object_inputs, const vespalib::string &expression) - : index_env(), rank(make_replacer()), deps(rank), setup_ok(false) + : stash(), index_env(), query_env(&index_env), rank(make_replacer()), deps(rank), setup_ok(false) { rank.setName("self"); index_env.getProperties().add("self.rankingScript", expression); @@ -147,4 +154,10 @@ TEST("require that replaced expressions override result type") { FeatureType::number())); } +TEST_F("require that replaced expressions create the appropriate executor", SetupResult({}, "foo")) { + EXPECT_TRUE(f1.setup_ok); + FeatureExecutor &executor = f1.rank.createExecutor(f1.query_env, f1.stash); + EXPECT_TRUE(dynamic_cast<DummyExecutor*>(&executor) != nullptr); +} + TEST_MAIN() { TEST_RUN_ALL(); } |