X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fxpath%2Fxpath4.c;h=b9da9853df5866f6f82119bcd3eef420419763f5;hb=e26fd4d7361802023a6264f406e98d71503050cd;hp=7b506564119563f774985d57803ab1f18dc11e42;hpb=3d3d0cebd23fa527a7e9d5d728e3c744acb37580;p=idzebra-moved-to-github.git diff --git a/test/xpath/xpath4.c b/test/xpath/xpath4.c index 7b50656..b9da985 100644 --- a/test/xpath/xpath4.c +++ b/test/xpath/xpath4.c @@ -1,5 +1,5 @@ -/* $Id: xpath4.c,v 1.4 2005-09-13 11:51:11 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: xpath4.c,v 1.8 2007-01-15 15:10:25 adam Exp $ + Copyright (C) 1995-2007 Index Data ApS This file is part of the Zebra server. @@ -15,9 +15,9 @@ 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. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "../api/testlib.h" @@ -83,70 +83,78 @@ const char *myrec[] = { 0}; -int main(int argc, char **argv) +static void tst(int argc, char **argv) { - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = tl_start_up(0, argc, argv); ZebraHandle zh = zebra_open(zs, 0); #if 0 yaz_log_init_level( yaz_log_mask_str_x("xpath4,rsbetween", LOG_DEFAULT_LEVEL)); #endif - init_data(zh, myrec); - -#define q(qry,hits) do_query(__LINE__,zh,qry,hits) + YAZ_CHECK(tl_init_data(zh, myrec)); - 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); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title foo",4)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title bar",2)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] foo",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] foo",1)); - q("@attr 1=/record/title[@lang='en'] english",1); - q("@attr 1=/record/title[@lang='da'] english",0); - q("@attr 1=/record/title[@lang='da'] danish",1); - q("@attr 1=/record/title[@lang='en'] danish",0); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] english",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] english",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='da'] danish",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title[@lang='en'] danish",0)); - q("@attr 1=/record/title @and foo bar",2); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/title @and foo bar",2)); /* The previous 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); + YAZ_CHECK(tl_query(zh, "@and @attr 1=/record/title foo @attr 1=/record/title bar ",2)); /* check we get all the occureences for 'grunt' */ /* this can only be seen in the log, with debugs on. bug #202 */ - q("@attr 1=/record/author grunt",3); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/author grunt",3)); /* check nested tags */ - q("@attr 1=/record/nested before",0); - q("@attr 1=/record/nested early",1); - q("@attr 1=/record/nested middle",1); - q("@attr 1=/record/nested late",1); - q("@attr 1=/record/nested after",0); - - q("@attr 1=/record/nested/nested before",0); - q("@attr 1=/record/nested/nested early",0); - q("@attr 1=/record/nested/nested middle",1); - q("@attr 1=/record/nested/nested late",0); - q("@attr 1=/record/nested/nested after",0); - - q("@attr 1=/record/nestattr[@level='outer'] before",0); - q("@attr 1=/record/nestattr[@level='outer'] early",1); - q("@attr 1=/record/nestattr[@level='outer'] middle",1); - q("@attr 1=/record/nestattr[@level='outer'] late",1); - q("@attr 1=/record/nestattr[@level='outer'] after",0); - - q("@attr 1=/record/nestattr[@level='inner'] before",0); - q("@attr 1=/record/nestattr[@level='inner'] early",0); - q("@attr 1=/record/nestattr[@level='inner'] middle",0); - q("@attr 1=/record/nestattr[@level='inner'] late",0); - q("@attr 1=/record/nestattr[@level='inner'] after",0); - - q("@attr 1=/record/nestattr/nestattr[@level='inner'] before",0); - q("@attr 1=/record/nestattr/nestattr[@level='inner'] early",0); - q("@attr 1=/record/nestattr/nestattr[@level='inner'] middle",1); - q("@attr 1=/record/nestattr/nestattr[@level='inner'] late",0); - q("@attr 1=/record/nestattr/nestattr[@level='inner'] after",0); - - return close_down(zh, zs, 0); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested early",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested middle",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested late",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested after",0)); + + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested early",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested middle",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested late",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nested/nested after",0)); + + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] early",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] middle",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] late",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='outer'] after",0)); + + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] early",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] middle",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] late",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr[@level='inner'] after",0)); + + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] before",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] early",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] middle",1)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] late",0)); + YAZ_CHECK(tl_query(zh, "@attr 1=/record/nestattr/nestattr[@level='inner'] after",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 + */ +