Sort Keys are stored using the reckeys_t structure. sort files
[idzebra-moved-to-github.git] / test / api / t10.c
index 0d2004f..4429132 100644 (file)
@@ -1,6 +1,6 @@
-/* $Id: t10.c,v 1.3 2004-10-29 13:02:39 heikki Exp $
-   Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
-   Index Data Aps
+/* $Id: t10.c,v 1.11 2006-05-10 08:13:35 adam Exp $
+   Copyright (C) 1995-2005
+   Index Data ApS
 
 This file is part of the Zebra server.
 
@@ -25,9 +25,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "testlib.h"
 #include "rankingrecords.h"
 
-#define qry(zh,query,hits,string,score) \
-    ranking_query(__LINE__,(zh),(query),(hits),(string),(score))
-
 struct tst {
     char *schema;
     char *hit1;
@@ -38,67 +35,71 @@ struct tst {
     int score3;
 };
 
-
-
 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", 0, "first title", 1000, "first title",1000 },
+    {"ntc-ntn", "first title", 0, "first title", 1000, "first title",1000 },
+    {"ntc-btn", "first title", 0, "first title", 1000, "first title",1000 },
+    {"ntc-apn", "first title", 0,    "first title", 1000, "first title",1000 },
+    {"ntc-npn", "first title", 0,    "first title", 1000, "first title",1000 },
+    {"ntc-bpn", "first title", 0,    "first title", 1000, "first title",1000 },
+    {"atc-atn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"atc-ntn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"atc-btn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"atc-apn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"atc-npn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"atc-bpn", "first title", 0,    "first title", 1000, "first title", 1000 },
+
+    {"npc-atn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"npc-ntn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"npc-btn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"npc-apn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"npc-npn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"npc-bpn", "first title", 0,    "first title", 1000, "first title", 1000 },
+
+    {"apc-atn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"apc-ntn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"apc-btn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"apc-apn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"apc-npn", "first title", 0,    "first title", 1000, "first title", 1000 },
+    {"apc-bpn", "first title", 0,    "first title", 1000, "first title", 1000 },
     {0,0,0,0,0,0,0},
 };
 
-int main(int argc, char **argv)
+static void tst(int argc, char **argv)
 {
     int i;
-    ZebraService zs = start_up("zebrazv.cfg", argc, argv);
-    ZebraHandle  zh = zebra_open (zs);
+    ZebraService zs = tl_start_up("zebrazv.cfg", argc, argv);
+    ZebraHandle zh = zebra_open(zs, 0);
   
-    init_data(zh, recs);
+    YAZ_CHECK(tl_init_data(zh, recs));
     zebra_close(zh);
-
-    yaz_log_init_level(LOG_ALL);
-    for (i=0; tests[i].schema; i++)
+    for (i = 0; tests[i].schema; i++)
     {
-        zh = zebra_open (zs);
-        zebra_select_database(zh, "Default");
-        zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema);
-        logf(LOG_LOG,"============%d: %s ============", i,tests[i].schema);
-
-        ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 the",
-                3, tests[i].hit1, tests[i].score1);
-        ranking_query( __LINE__, zh, "@attr 1=1016 @attr 2=102 @or foo bar",
-                3, tests[i].hit2, tests[i].score2);
-        ranking_query( __LINE__, zh, 
-                "@attr 1=1016 @attr 2=102 @or @or the foo bar",
-                3, tests[i].hit3, tests[i].score3);
+        zh = zebra_open(zs, 0);
+       YAZ_CHECK(zh);
+        YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
 
+        zebra_set_resource(zh, "zvrank.weighting-scheme", tests[i].schema);
+        yaz_log(YLOG_LOG,"============%d: %s ===========", i, tests[i].schema);
+
+        YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 the",
+                                  3, tests[i].hit1, tests[i].score1));
+        YAZ_CHECK(tl_ranking_query(zh, "@attr 1=1016 @attr 2=102 @or foo bar",
+                                  3, tests[i].hit2, tests[i].score2));
+        YAZ_CHECK(tl_ranking_query(zh, 
+                                  "@attr 1=1016 @attr 2=102 @or @or the foo bar",
+                                  3, tests[i].hit3, tests[i].score3));
         zebra_close(zh);
     }
-    
-    return close_down(0,zs,0);
+    YAZ_CHECK(tl_close_down(0, zs));
 }
+
+TL_MAIN
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+