X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fapi%2Ft10.c;h=eb99c1b61a19fe65c71dd920245e440e3dd45d93;hb=18525dd52e7b562b9ff31987fbee4be16c68f4b8;hp=f333448c3bfb12fdbc7da75cc2a96bbf31bfa6d5;hpb=2fefff35eeb40ba802bb3ee11674a6037b84659c;p=idzebra-moved-to-github.git diff --git a/test/api/t10.c b/test/api/t10.c index f333448..eb99c1b 100644 --- a/test/api/t10.c +++ b/test/api/t10.c @@ -1,4 +1,4 @@ -/* $Id: t10.c,v 1.1 2004-10-28 10:37:15 heikki Exp $ +/* $Id: t10.c,v 1.4 2004-11-04 13:09:49 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -22,14 +22,11 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA /** t10.c - test zv-rank */ -#include -#include -#include #include "testlib.h" #include "rankingrecords.h" #define qry(zh,query,hits,string,score) \ - RankingQuery(__LINE__,(zh),(query),(hits),(string),(score)) + ranking_query(__LINE__,(zh),(query),(hits),(string),(score)) struct tst { char *schema; @@ -44,33 +41,33 @@ struct tst { struct tst tests[] = { - {"ntc-atn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"ntc-ntn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"ntc-btn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"ntc-apn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"ntc-npn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"ntc-bpn", "first title", 1000, "first title", 1000, "third title", 826 }, - - {"atc-atn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"atc-ntn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"atc-btn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"atc-apn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"atc-npn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"atc-bpn", "first title", 1000, "first title", 1000, "first title", 972 }, - - {"npc-atn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"npc-ntn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"npc-btn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"npc-apn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"npc-npn", "first title", 1000, "first title", 1000, "third title", 826 }, - {"npc-bpn", "first title", 1000, "first title", 1000, "third title", 826 }, - - {"apc-atn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"apc-ntn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"apc-btn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"apc-apn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"apc-npn", "first title", 1000, "first title", 1000, "first title", 972 }, - {"apc-bpn", "first title", 1000, "first title", 1000, "first title", 972 }, + {"ntc-atn", "first title", 1000, "first title", 1000, "second title",862 }, + {"ntc-ntn", "first title", 1000, "first title", 1000, "second title",862 }, + {"ntc-btn", "first title", 1000, "first title", 1000, "second title",862 }, + {"ntc-apn", "first title", 1000, "first title", 1000, "second title",862 }, + {"ntc-npn", "first title", 1000, "first title", 1000, "second title",862 }, + {"ntc-bpn", "first title", 1000, "first title", 1000, "second title",862 }, + + {"atc-atn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"atc-ntn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"atc-btn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"atc-apn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"atc-npn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"atc-bpn", "first title", 1000, "first title", 1000, "second title", 989 }, + + {"npc-atn", "first title", 1000, "first title", 1000, "second title", 862 }, + {"npc-ntn", "first title", 1000, "first title", 1000, "second title", 862 }, + {"npc-btn", "first title", 1000, "first title", 1000, "second title", 862 }, + {"npc-apn", "first title", 1000, "first title", 1000, "second title", 862 }, + {"npc-npn", "first title", 1000, "first title", 1000, "second title", 862 }, + {"npc-bpn", "first title", 1000, "first title", 1000, "second title", 862 }, + + {"apc-atn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"apc-ntn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"apc-btn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"apc-apn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"apc-npn", "first title", 1000, "first title", 1000, "second title", 989 }, + {"apc-bpn", "first title", 1000, "first title", 1000, "second title", 989 }, {0,0,0,0,0,0,0}, }; @@ -78,39 +75,13 @@ struct tst tests[] = { int main(int argc, char **argv) { int i; - char *addinfo; - ZebraService zs; - ZebraHandle zh; - - yaz_log_init_file("t10.log"); - /* yaz_log_init_level(LOG_ALL); */ - - nmem_init (); - - zs = start_service("zebrazv.cfg"); - zh = zebra_open (zs); - zebra_select_database(zh, "Default"); - logf(LOG_LOG,"going to call init"); - i=zebra_init(zh); - logf(LOG_LOG,"init returned %d",i); - if (i) { - printf("init failed with %d\n",i); - zebra_result(zh, &i, &addinfo); - printf(" Error %d %s\n",i,addinfo); - exit(1); - } - - zebra_begin_trans (zh, 1); - for (i = 0; recs[i]; i++) - zebra_add_record (zh, recs[i], strlen(recs[i])); - zebra_end_trans (zh); - zebra_commit (zh); + ZebraService zs = start_up("zebrazv.cfg", argc, argv); + ZebraHandle zh = zebra_open (zs); - // yaz_log_init_level(LOG_ALL); - + int loglevel=yaz_log_mask_str("zvrank,rank1,t10"); + init_data(zh, recs); zebra_close(zh); - - + yaz_log_init_level(loglevel); for (i=0; tests[i].schema; i++) { zh = zebra_open (zs); @@ -118,21 +89,16 @@ int main(int argc, char **argv) zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema); logf(LOG_LOG,"============%d: %s ============", i,tests[i].schema); - RankingQuery( __LINE__, zh, "@attr 1=1016 @attr 2=102 the", + ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 the", 3, tests[i].hit1, tests[i].score1); - RankingQuery( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or foo bar", + ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or foo bar", 3, tests[i].hit2, tests[i].score2); - RankingQuery( __LINE__, zh, + ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or @or the foo bar", 3, tests[i].hit3, tests[i].score3); zebra_close(zh); } - zebra_stop (zs); - - nmem_exit (); - xmalloc_trav ("x"); - logf(LOG_LOG,"============ ALL TESTS PASSED OK ============"); - exit (0); + return close_down(0,zs,0); }