X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fapi%2Ft7.c;h=d5ce6eace8002d45ba365135771758b7138d8142;hb=6ba9698e88c0283e40fa5980a1a6b551fff2d597;hp=f943cbe7bc1a0a8bac63cbc5aac9c83854f5fca2;hpb=f84ad20a7a6a45d02da7f162fa6bb1137e79a07f;p=idzebra-moved-to-github.git diff --git a/test/api/t7.c b/test/api/t7.c index f943cbe..d5ce6ea 100644 --- a/test/api/t7.c +++ b/test/api/t7.c @@ -1,6 +1,6 @@ -/* $Id: t7.c,v 1.4 2004-10-29 13:02:39 heikki Exp $ - Copyright (C) 2004 - Index Data Aps +/* $Id: t7.c,v 1.12 2006-05-10 08:13:35 adam Exp $ + Copyright (C) 1995-2005 + Index Data ApS This file is part of the Zebra server. @@ -31,58 +31,61 @@ const char *recs[] = { "\n", 0}; - -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); - ZebraHandle zh = zebra_open (zs); - - const char *setname1="set1"; - const char *setname2="set2"; - const char *setname3="set3"; + const char *setname1 = "set1"; + const char *setname2 = "set2"; + const char *setname3 = "set3"; int status; - int rc; + ZebraService zs = tl_start_up(0, argc, argv); + ZebraHandle zh = zebra_open (zs, 0); ODR odr_input = odr_createmem (ODR_DECODE); ODR odr_output = odr_createmem (ODR_ENCODE); YAZ_PQF_Parser parser = yaz_pqf_create(); - Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, - "@attr 1=4 my"); - Z_SortKeySpecList *spec = - yaz_sort_spec (odr_output, "@attr 1=4 id"); - int hits; - - init_data(zh,recs); + Z_RPNQuery *query = yaz_pqf_parse(parser, odr_input, "@attr 1=4 my"); + Z_SortKeySpecList *spec = yaz_sort_spec (odr_output, "1=4 <"); + zint hits; + YAZ_CHECK(tl_init_data(zh, recs)); - zebra_begin_trans (zh, 0); + YAZ_CHECK(zebra_begin_trans(zh, 0) == ZEBRA_OK); - zebra_search_RPN (zh, odr_input, query, setname1, &hits); - - rc=zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, &status); - if (rc) - { - printf("sort A returned %d %d \n",rc,status); - exit(1); - } - - rc=zebra_sort(zh, odr_output, 1, &setname2, setname3, spec, &status); - if (rc) - { - printf("sort B returned %d %d \n",rc,status); - exit(1); - } - - zebra_end_trans (zh); + YAZ_CHECK(zebra_search_RPN(zh, odr_input, query, setname1, &hits) == + ZEBRA_OK); + + YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, + &status) + == ZEBRA_OK); + YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname2, setname3, spec, + &status) == ZEBRA_OK); + + spec = yaz_sort_spec(odr_output, "1=5 <"); /* invalid sort spec */ + + YAZ_CHECK(zebra_sort(zh, odr_output, 1, &setname1, setname2, spec, + &status) == ZEBRA_FAIL); + + YAZ_CHECK(zebra_end_trans(zh) == ZEBRA_OK); + yaz_pqf_destroy(parser); /* - zebra_deleleResultSet(zh, Z_DeleteRequest_list, + zebra_deleteResultSet(zh, Z_DeleteRequest_list, 1, &setnamep, &status); */ - odr_destroy (odr_input); - odr_destroy (odr_output); + odr_destroy(odr_input); + odr_destroy(odr_output); - zebra_commit (zh); + zebra_commit(zh); - return close_down(zh,zs,0); + YAZ_CHECK(tl_close_down(zh, zs)); } + +TL_MAIN +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +