1 /* $Id: t10.c,v 1.2 2004-10-28 15:24:36 heikki Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /** t10.c - test zv-rank */
26 #include <yaz/pquery.h>
27 #include <idzebra/api.h>
30 #include "rankingrecords.h"
32 #define qry(zh,query,hits,string,score) \
33 RankingQuery(__LINE__,(zh),(query),(hits),(string),(score))
47 struct tst tests[] = {
48 {"ntc-atn", "first title", 1000, "first title", 1000, "third title", 826 },
49 {"ntc-ntn", "first title", 1000, "first title", 1000, "third title", 826 },
50 {"ntc-btn", "first title", 1000, "first title", 1000, "third title", 826 },
51 {"ntc-apn", "first title", 1000, "first title", 1000, "third title", 826 },
52 {"ntc-npn", "first title", 1000, "first title", 1000, "third title", 826 },
53 {"ntc-bpn", "first title", 1000, "first title", 1000, "third title", 826 },
55 {"atc-atn", "first title", 1000, "first title", 1000, "first title", 972 },
56 {"atc-ntn", "first title", 1000, "first title", 1000, "first title", 972 },
57 {"atc-btn", "first title", 1000, "first title", 1000, "first title", 972 },
58 {"atc-apn", "first title", 1000, "first title", 1000, "first title", 972 },
59 {"atc-npn", "first title", 1000, "first title", 1000, "first title", 972 },
60 {"atc-bpn", "first title", 1000, "first title", 1000, "first title", 972 },
62 {"npc-atn", "first title", 1000, "first title", 1000, "third title", 826 },
63 {"npc-ntn", "first title", 1000, "first title", 1000, "third title", 826 },
64 {"npc-btn", "first title", 1000, "first title", 1000, "third title", 826 },
65 {"npc-apn", "first title", 1000, "first title", 1000, "third title", 826 },
66 {"npc-npn", "first title", 1000, "first title", 1000, "third title", 826 },
67 {"npc-bpn", "first title", 1000, "first title", 1000, "third title", 826 },
69 {"apc-atn", "first title", 1000, "first title", 1000, "first title", 972 },
70 {"apc-ntn", "first title", 1000, "first title", 1000, "first title", 972 },
71 {"apc-btn", "first title", 1000, "first title", 1000, "first title", 972 },
72 {"apc-apn", "first title", 1000, "first title", 1000, "first title", 972 },
73 {"apc-npn", "first title", 1000, "first title", 1000, "first title", 972 },
74 {"apc-bpn", "first title", 1000, "first title", 1000, "first title", 972 },
79 int main(int argc, char **argv)
85 yaz_log_init_file("t10.log");
86 /* yaz_log_init_level(LOG_ALL); */
90 zs = start_service("zebrazv.cfg");
99 for (i=0; tests[i].schema; i++)
101 zh = zebra_open (zs);
102 zebra_select_database(zh, "Default");
103 zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema);
104 logf(LOG_LOG,"============%d: %s ============", i,tests[i].schema);
106 RankingQuery( __LINE__, zh, "@attr 1=1016 @attr 2=102 the",
107 3, tests[i].hit1, tests[i].score1);
108 RankingQuery( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or foo bar",
109 3, tests[i].hit2, tests[i].score2);
110 RankingQuery( __LINE__, zh,
111 "@attr 1=1016 @attr 2=102 @or @or the foo bar",
112 3, tests[i].hit3, tests[i].score3);
121 logf(LOG_LOG,"============ ALL TESTS PASSED OK ============");