1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/searchlib/fef/fef.h>
#include <vespa/searchlib/fef/test/indexenvironment.h>
#include <vespa/searchlib/fef/test/plugin/setup.h>
#include <vespa/searchlib/features/valuefeature.h>
using namespace search::features;
using namespace search::fef::test;
using namespace search::fef;
struct RankFixture {
BlueprintFactory factory;
IndexEnvironment indexEnv;
RankFixture() : factory(), indexEnv() {
setup_fef_test_plugin(factory);
factory.addPrototype(Blueprint::SP(new ValueBlueprint()));
}
bool verify(const std::string &feature) const {
return verifyFeature(factory, indexEnv, feature, "feature verification test");
}
};
TEST_F("verify valid rank feature", RankFixture) {
EXPECT_TRUE(f1.verify("value(1, 2, 3).0"));
EXPECT_TRUE(f1.verify("value(1, 2, 3).1"));
EXPECT_TRUE(f1.verify("value(1, 2, 3).2"));
}
TEST_F("verify unknown feature", RankFixture) {
EXPECT_FALSE(f1.verify("unknown"));
}
TEST_F("verify unknown output", RankFixture) {
EXPECT_FALSE(f1.verify("value(1, 2, 3).3"));
}
TEST_F("verify illegal input parameters", RankFixture) {
EXPECT_FALSE(f1.verify("value.0"));
}
TEST_F("verify illegal feature name", RankFixture) {
EXPECT_FALSE(f1.verify("value(2)."));
}
TEST_F("verify too deep dependency graph", RankFixture) {
EXPECT_TRUE(f1.verify("chain(basic, 63, 4)"));
EXPECT_FALSE(f1.verify("chain(basic, 64, 4)"));
}
TEST_F("verify dependency cycle", RankFixture) {
EXPECT_FALSE(f1.verify("chain(cycle, 4, 2)"));
}
TEST_MAIN() { TEST_RUN_ALL(); }
|