aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/tests/proton/verify_ranksetup
diff options
context:
space:
mode:
authorHaavard <havardpe@yahoo-inc.com>2016-09-01 13:27:02 +0000
committerHaavard <havardpe@yahoo-inc.com>2016-09-01 13:27:02 +0000
commitb21f365ac2d2ed9d802c55e96cccd9d7f1f75633 (patch)
tree7e3fea0cf3061b4acae95c42ef0596a6aee6592b /searchcore/src/tests/proton/verify_ranksetup
parent3b6a878a2dfea4ca053758196f74fbf0e750f6ea (diff)
added tests for ranking constants
Diffstat (limited to 'searchcore/src/tests/proton/verify_ranksetup')
-rw-r--r--searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp
index 3db23380675..2ddcb154e84 100644
--- a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp
+++ b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp
@@ -48,6 +48,7 @@ struct Model {
std::map<std::string,std::pair<std::string,std::string> > indexes;
std::map<std::string,std::pair<std::string,std::string> > attributes;
std::map<std::string,std::string> properties;
+ std::map<std::string,std::string> constants;
std::vector<bool> extra_profiles;
Model() : indexes(), attributes(), properties(), extra_profiles() {
verify_dir();
@@ -118,10 +119,20 @@ struct Model {
out.fmt("rankprofile[%zu].fef.property[%zu].value \"%s\"\n", i, i, extra_profiles[i-1]?valid_feature:invalid_feature);
}
}
+ void write_ranking_constants(const Writer &out) {
+ size_t idx = 0;
+ for (const auto &entry: constants) {
+ out.fmt("constant[%zu].name \"%s\"\n", idx, entry.first.c_str());
+ out.fmt("constant[%zu].fileref \"12345\"\n", idx);
+ out.fmt("constant[%zu].type \"%s\"\n", idx, entry.second.c_str());
+ ++idx;
+ }
+ }
void generate() {
write_attributes(Writer(gen_dir + "/attributes.cfg"));
write_indexschema(Writer(gen_dir + "/indexschema.cfg"));
write_rank_profiles(Writer(gen_dir + "/rank-profiles.cfg"));
+ write_ranking_constants(Writer(gen_dir + "/ranking-constants.cfg"));
}
bool verify() {
generate();
@@ -155,6 +166,7 @@ struct SimpleModel : Model {
index("list", Schema::STRING, Schema::ARRAY);
index("keywords", Schema::STRING, Schema::WEIGHTEDSET);
attribute("date", Schema::INT32, Schema::SINGLE);
+ constants["my_tensor"] = "tensor(x{},y{})";
}
};
@@ -241,6 +253,16 @@ TEST_F("require that shadowed attributes can be used", ShadowModel()) {
EXPECT_TRUE(f.verify());
}
+TEST_F("require that ranking constants can be used", SimpleModel()) {
+ f.first_phase("constant(my_tensor)");
+ EXPECT_TRUE(f.verify());
+}
+
+TEST_F("require that undefined ranking constants cannot be used", SimpleModel()) {
+ f.first_phase("constant(bogus_tensor)");
+ EXPECT_FALSE(f.verify());
+}
+
//-----------------------------------------------------------------------------
TEST_F("cleanup files", Model()) {