X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftstodrstack.c;h=96788c23258b05298700b04e0bbb814c707be64e;hb=c168cffc46e3b2b66e66e48f94f8e87b6566702b;hp=8088c1902c7f547fb4a5458328151dcc5ff38d21;hpb=be5342e415872d9f43511f7b68fbcec42dc2c0a7;p=yaz-moved-to-github.git diff --git a/test/tstodrstack.c b/test/tstodrstack.c index 8088c19..96788c2 100644 --- a/test/tstodrstack.c +++ b/test/tstodrstack.c @@ -1,20 +1,61 @@ +/* + * Copyright (C) 1995-2005, Index Data ApS + * See the file LICENSE for details. + * + * $Id: tstodrstack.c,v 1.4 2006-01-29 21:59:13 adam Exp $ + * + */ #include #include #include +#include +/** \brief build a 100 level query */ void test1() { ODR odr = odr_createmem(ODR_ENCODE); YAZ_PQF_Parser parser = yaz_pqf_create(); Z_RPNQuery *rpn_query; + char qstr[10000]; + int i; + int ret; + + YAZ_CHECK(odr); + YAZ_CHECK(parser); + + *qstr = '\0'; + for (i = 0; i<100; i++) + strcat(qstr, "@and 1 "); + strcat(qstr, "1"); + + rpn_query = yaz_pqf_parse (parser, odr, qstr); + YAZ_CHECK(rpn_query); + + ret = z_RPNQuery(odr, &rpn_query, 0, 0); + YAZ_CHECK(ret); + + yaz_pqf_destroy(parser); + odr_destroy(odr); +} + +/** \brief build a circular referenced query */ +void test2() +{ + ODR odr = odr_createmem(ODR_ENCODE); + YAZ_PQF_Parser parser = yaz_pqf_create(); + Z_RPNQuery *rpn_query; + int ret; + + YAZ_CHECK(odr); rpn_query = yaz_pqf_parse (parser, odr, "@and @and a b c"); + YAZ_CHECK(rpn_query); - if (!rpn_query) - exit(1); + /* make the circular reference */ rpn_query->RPNStructure->u.complex->s1 = rpn_query->RPNStructure; - z_RPNQuery(odr, &rpn_query, 0, 0); + ret = z_RPNQuery(odr, &rpn_query, 0, 0); /* should fail */ + YAZ_CHECK(!ret); yaz_pqf_destroy(parser); odr_destroy(odr); @@ -22,8 +63,10 @@ void test1() int main(int argc, char **argv) { + YAZ_CHECK_INIT(argc, argv); test1(); - exit(0); + test2(); + YAZ_CHECK_TERM; } /* * Local variables: