1 /* $Id: t7.c,v 1.12 2006-05-10 08:13:35 adam Exp $
2 Copyright (C) 1995-2005
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
26 #include <yaz/sortspec.h>
28 const char *recs[] = {
30 " <title>My title</title>\n"
34 static void tst(int argc, char **argv)
36 const char *setname1 = "set1";
37 const char *setname2 = "set2";
38 const char *setname3 = "set3";
40 ZebraService zs = tl_start_up(0, argc, argv);
41 ZebraHandle zh = zebra_open (zs, 0);
42 ODR odr_input = odr_createmem (ODR_DECODE);
43 ODR odr_output = odr_createmem (ODR_ENCODE);
44 YAZ_PQF_Parser parser = yaz_pqf_create();
45 Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my");
46 Z_SortKeySpecList *spec = yaz_sort_spec (odr_output, "1=4 <");
49 YAZ_CHECK(tl_init_data(zh, recs));
51 YAZ_CHECK(zebra_begin_trans(zh, 0) == ZEBRA_OK);
53 YAZ_CHECK(zebra_search_RPN(zh, odr_input, query, setname1, &hits) ==
56 YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec,
59 YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname2, setname3, spec,
60 &status) == ZEBRA_OK);
62 spec = yaz_sort_spec(odr_output, "1=5 <"); /* invalid sort spec */
64 YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec,
65 &status) == ZEBRA_FAIL);
67 YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK);
69 yaz_pqf_destroy(parser);
72 zebra_deleteResultSet(zh, Z_DeleteRequest_list,
73 1, &setnamep, &status);
75 odr_destroy(odr_input);
76 odr_destroy(odr_output);
80 YAZ_CHECK(tl_close_down(zh, zs));
87 * indent-tabs-mode: nil
89 * vim: shiftwidth=4 tabstop=8 expandtab