From ae8b5430a1c36e6b53abd04577757b58c8e5cd65 Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Fri, 29 Oct 2004 14:16:22 +0000 Subject: [PATCH] Added xpath tests in test/api, disables test/xpath --- test/Makefile.am | 2 +- test/api/Makefile.am | 7 ++-- test/api/xpath2.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++ test/api/xpath3.c | 56 ++++++++++++++++++++++++++++++++ test/api/xpath4.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ test/api/zebraxpath.cfg | 10 ++++++ test/xpath/README | 4 +++ 7 files changed, 238 insertions(+), 3 deletions(-) create mode 100644 test/api/xpath2.c create mode 100644 test/api/xpath3.c create mode 100644 test/api/xpath4.c create mode 100644 test/api/zebraxpath.cfg create mode 100644 test/xpath/README diff --git a/test/Makefile.am b/test/Makefile.am index 4682121..072ba96 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=codec api gils malxml config usmarc dmoz xpath sort sort2 xelm cddb \ +SUBDIRS=codec api gils malxml config usmarc dmoz sort sort2 xelm cddb \ rusmarc zsh marcxml charmap diff --git a/test/api/Makefile.am b/test/api/Makefile.am index 3af503d..e06be66 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -1,10 +1,10 @@ -# $Id: Makefile.am,v 1.22 2004-10-29 13:02:39 heikki Exp $ +# $Id: Makefile.am,v 1.23 2004-10-29 14:16:22 heikki Exp $ noinst_PROGRAMS = testclient testclient_SOURCES = testclient.c simpletests = t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 -xpathtests= xpath1 +xpathtests= xpath1 xpath2 xpath3 xpath4 #check_PROGRAMS = t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 xpath1 check_PROGRAMS = ${simpletests} ${xpathtests} TESTS = $(check_PROGRAMS) @@ -23,6 +23,9 @@ t9_SOURCES = t9.c testlib.c testlib.h rankingrecords.h t10_SOURCES = t10.c testlib.c testlib.h rankingrecords.h xpath1_SOURCES = xpath1.c testlib.c testlib.h +xpath2_SOURCES = xpath2.c testlib.c testlib.h +xpath3_SOURCES = xpath3.c testlib.c testlib.h +xpath4_SOURCES = xpath4.c testlib.c testlib.h AM_CPPFLAGS = -I$(top_srcdir)/include $(YAZINC) diff --git a/test/api/xpath2.c b/test/api/xpath2.c new file mode 100644 index 0000000..f6409d9 --- /dev/null +++ b/test/api/xpath2.c @@ -0,0 +1,83 @@ +/* $Id: xpath2.c,v 1.1 2004-10-29 14:16:22 heikki Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 + Index Data Aps + +This file is part of the Zebra server. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Zebra; see the file LICENSE.zebra. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +*/ + +#include "testlib.h" + + +/** xpath2.c - index a a bit more complex sgml record and search in it */ + +const char *myrec[] = { + " \n" + " 10 \n" + " Sauropoda \n" + " PT \n" + " \n" + " BT \n" + " 5 \n" + " Brontosauria \n" + " PT \n" + " \n" + " \n" + " NT \n" + " 11 \n" + " Eusauropoda \n" + " PT \n" + " \n" + " \n", + + " \n" + " 5 \n" + " Brontosauria \n" + " PT \n" + " \n" + " BT \n" + " 4 \n" + " Sauropodomorpha \n" + " PT \n" + " \n" + " \n" + " NT \n" + " 6 \n" + " Plateosauria \n" + " PT \n" + " \n" + " \n" + " NT \n" + " 10 \n" + " Sauropoda \n" + " PT \n" + " \n" + " \n", + 0}; + + +int main(int argc, char **argv) +{ + ZebraService zs = start_up("zebraxpath.cfg", argc, argv); + ZebraHandle zh = zebra_open (zs); + init_data(zh,myrec); + + do_query(__LINE__,zh, "@attr 1=/Zthes/termName Sauropoda", 1); + do_query(__LINE__,zh, "@attr 1=/Zthes/relation/termName Sauropoda",1); + + return close_down(zh, zs, 0); +} diff --git a/test/api/xpath3.c b/test/api/xpath3.c new file mode 100644 index 0000000..d7161d4 --- /dev/null +++ b/test/api/xpath3.c @@ -0,0 +1,56 @@ + +/* $Id: xpath3.c,v 1.1 2004-10-29 14:16:22 heikki Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 + Index Data Aps + +This file is part of the Zebra server. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Zebra; see the file LICENSE.zebra. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +*/ + +#include "testlib.h" + + +/** xpath3.c - attributes, with Danish characters */ + +const char *myrec[] = { + " \n" + " \n" + " content \n" + " content \n" + " \n" + " content \n" + " \n", + 0}; + + +int main(int argc, char **argv) +{ + ZebraService zs = start_up("zebraxpath.cfg", argc, argv); + ZebraHandle zh = zebra_open (zs); + init_data(zh,myrec); + +#define q(qry,hits) do_query(__LINE__,zh,qry,hits) + + q("@attr 1=/root content",1); + q("@attr 1=/root/first content",1); + q("@attr {1=/root/first[@attr='danish']} content",1); + q("@attr {1=/root/second[@attr='danish lake']} content",1); + /*q("@attr {1=/root/third[@attr='dansk sø']} content",1); */ + /* FIXME - This triggers bug200 */ + + return close_down(zh, zs, 0); +} diff --git a/test/api/xpath4.c b/test/api/xpath4.c new file mode 100644 index 0000000..993bc2a --- /dev/null +++ b/test/api/xpath4.c @@ -0,0 +1,79 @@ + + +/* $Id: xpath4.c,v 1.1 2004-10-29 14:16:22 heikki Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 + Index Data Aps + +This file is part of the Zebra server. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Zebra; see the file LICENSE.zebra. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +*/ + +#include "testlib.h" + + +/** xpath4.c - Attributes */ + +const char *myrec[] = { + " \n" + " foo \n" + " bar \n" + " gryf \n" + " \n", + + " \n" + " foo bar \n" + " gryf \n" + " \n", + + " \n" + " foo gryf \n" + " grunt \n" + " \n", + + " \n" + " foo grunt \n" + " bar \n" + " \n", + + " \n" + " hamlet \n" + " foo bar grunt \n" + " \n", + + 0}; + + +int main(int argc, char **argv) +{ + ZebraService zs = start_up("zebraxpath.cfg", argc, argv); + ZebraHandle zh = zebra_open (zs); + init_data(zh,myrec); + +#define q(qry,hits) do_query(__LINE__,zh,qry,hits) + + q("@attr 1=/record/title foo",4); + q("@attr 1=/record/title bar",2); + q("@attr 1=/record/title[@lang='da'] foo",1); + q("@attr 1=/record/title[@lang='en'] foo",1); + q("@attr 1=/record/title @and foo bar",2); + /* The last one returns two hits, as the and applies to the whole + record, so it matches foobar + This might not have to be like that, but currently that is what + zebra does. */ + q("@and @attr 1=/record/title foo @attr 1=/record/title bar ",2); + return close_down(zh, zs, 0); +} diff --git a/test/api/zebraxpath.cfg b/test/api/zebraxpath.cfg new file mode 100644 index 0000000..53ab90f --- /dev/null +++ b/test/api/zebraxpath.cfg @@ -0,0 +1,10 @@ +# $Id: zebraxpath.cfg,v 1.1 2004-10-29 14:16:22 heikki Exp $ +profilePath: ${srcdir:-.}/../../tab +recordType: grs.sgml +attset: bib1.att + +isam:b + + + + diff --git a/test/xpath/README b/test/xpath/README new file mode 100644 index 0000000..7213515 --- /dev/null +++ b/test/xpath/README @@ -0,0 +1,4 @@ + +the xpath tests have been moved into test/api/xpath*.c +This directory is not used any more, and should be deleted + -- 1.7.10.4