diff options
author | Håvard Pettersen <havardpe@oath.com> | 2020-03-13 15:00:14 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2020-03-18 12:28:18 +0000 |
commit | 7d779cf1f6221aea30d0fff92bac6f04e6658c23 (patch) | |
tree | 4b9939a659d6c0ee4b6bad77162e0bb0a9b31d91 /searchlib/src/tests/fef | |
parent | 476d295ec2d3a6e4d980d989a1747b5afec1b29b (diff) |
print first error for each feature
Diffstat (limited to 'searchlib/src/tests/fef')
-rw-r--r-- | searchlib/src/tests/fef/object_passing/object_passing_test.cpp | 11 | ||||
-rw-r--r-- | searchlib/src/tests/fef/resolver/resolver_test.cpp | 73 |
2 files changed, 27 insertions, 57 deletions
diff --git a/searchlib/src/tests/fef/object_passing/object_passing_test.cpp b/searchlib/src/tests/fef/object_passing/object_passing_test.cpp index ce9585f11cb..793b2d40ed3 100644 --- a/searchlib/src/tests/fef/object_passing/object_passing_test.cpp +++ b/searchlib/src/tests/fef/object_passing/object_passing_test.cpp @@ -59,10 +59,13 @@ struct ProxyBlueprint : Blueprint { } bool setup(const IIndexEnvironment &, const std::vector<vespalib::string> ¶ms) override { ASSERT_EQUAL(1u, params.size()); - object_input = defineInput(params[0], accept_input); - describeOutput("value", "the value", object_output ? FeatureType::object(ValueType::double_type()) : FeatureType::number()); - describeOutput("was_object", "whether input was object", FeatureType::number()); - return true; + if (auto input = defineInput(params[0], accept_input)) { + object_input = input.value().is_object(); + describeOutput("value", "the value", object_output ? FeatureType::object(ValueType::double_type()) : FeatureType::number()); + describeOutput("was_object", "whether input was object", FeatureType::number()); + return true; + } + return false; } FeatureExecutor &createExecutor(const IQueryEnvironment &, vespalib::Stash &stash) const override { return stash.create<ProxyExecutor>(object_input, object_output); diff --git a/searchlib/src/tests/fef/resolver/resolver_test.cpp b/searchlib/src/tests/fef/resolver/resolver_test.cpp index 7591d028620..72076f3999e 100644 --- a/searchlib/src/tests/fef/resolver/resolver_test.cpp +++ b/searchlib/src/tests/fef/resolver/resolver_test.cpp @@ -1,19 +1,15 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/fef/fef.h> #include <vespa/searchlib/fef/test/indexenvironment.h> #include <vespa/searchlib/features/valuefeature.h> #include <vespa/searchlib/features/rankingexpressionfeature.h> -#include <vespa/log/log.h> -LOG_SETUP("resolver_test"); - +using namespace search; +using namespace search::fef; using search::features::RankingExpressionBlueprint; -namespace search { -namespace fef { - class BaseBlueprint : public Blueprint { public: BaseBlueprint() : Blueprint("base") { } @@ -46,9 +42,9 @@ public: virtual bool setup(const IIndexEnvironment & indexEnv, const ParameterList & params) override { (void) indexEnv; (void) params; - defineInput("base.foo"); - defineInput("base.bar"); - defineInput("base.baz"); + ASSERT_TRUE(defineInput("base.foo")); + ASSERT_TRUE(defineInput("base.bar")); + ASSERT_TRUE(defineInput("base.baz")); describeOutput("out", "out"); return true; } @@ -57,66 +53,37 @@ public: } }; -class Test : public vespalib::TestApp { -private: - BlueprintFactory _factory; - void requireThatWeGetUniqueBlueprints(); - void require_that_bad_input_is_handled(); -public: - Test(); - ~Test(); - int Main() override; +struct Fixture { + BlueprintFactory factory; + Fixture() { + factory.addPrototype(Blueprint::SP(new BaseBlueprint())); + factory.addPrototype(Blueprint::SP(new CombineBlueprint())); + factory.addPrototype(std::make_shared<RankingExpressionBlueprint>()); + } }; -Test::Test() : - _factory() -{ - _factory.addPrototype(Blueprint::SP(new BaseBlueprint())); - _factory.addPrototype(Blueprint::SP(new CombineBlueprint())); - _factory.addPrototype(std::make_shared<RankingExpressionBlueprint>()); -} -Test::~Test() {} - -void -Test::requireThatWeGetUniqueBlueprints() -{ +TEST_F("requireThatWeGetUniqueBlueprints", Fixture()) { test::IndexEnvironment ienv; - BlueprintResolver::SP res(new BlueprintResolver(_factory, ienv)); + BlueprintResolver::SP res(new BlueprintResolver(f.factory, ienv)); res->addSeed("combine"); EXPECT_TRUE(res->compile()); const BlueprintResolver::ExecutorSpecList & spec = res->getExecutorSpecs(); - EXPECT_EQUAL(2u, spec.size()); + ASSERT_EQUAL(2u, spec.size()); EXPECT_TRUE(dynamic_cast<BaseBlueprint *>(spec[0].blueprint.get()) != NULL); EXPECT_TRUE(dynamic_cast<CombineBlueprint *>(spec[1].blueprint.get()) != NULL); } -void -Test::require_that_bad_input_is_handled() -{ +TEST_F("require_that_bad_input_is_handled", Fixture) { test::IndexEnvironment ienv; ienv.getProperties().add(indexproperties::eval::LazyExpressions::NAME, "false"); ienv.getProperties().add("rankingExpression(badinput).rankingScript", "base.foobad + base.bar"); - BlueprintResolver::SP res(new BlueprintResolver(_factory, ienv)); + BlueprintResolver::SP res(new BlueprintResolver(f.factory, ienv)); res->addSeed("rankingExpression(badinput)"); EXPECT_FALSE(res->compile()); const BlueprintResolver::ExecutorSpecList & spec = res->getExecutorSpecs(); - EXPECT_EQUAL(2u, spec.size()); + ASSERT_EQUAL(2u, spec.size()); EXPECT_TRUE(dynamic_cast<BaseBlueprint *>(spec[0].blueprint.get()) != nullptr); EXPECT_TRUE(dynamic_cast<RankingExpressionBlueprint *>(spec[1].blueprint.get()) != nullptr); } -int -Test::Main() -{ - TEST_INIT("resolver_test"); - - requireThatWeGetUniqueBlueprints(); - require_that_bad_input_is_handled(); - - TEST_DONE(); -} - -} -} - -TEST_APPHOOK(search::fef::Test); +TEST_MAIN() { TEST_RUN_ALL(); } |