X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftstmatchstr.c;h=bdb9751223c6b9e2d258ab715a97d9a141110537;hb=055f23ee3692349a03f681ef1a0d5fd70c0cc770;hp=e20cce8f41ca9bda336d00bb548a5fa84af009f0;hpb=fb6d99a0c7e07d9cc4a315c447deaf6564a85505;p=yaz-moved-to-github.git diff --git a/test/tstmatchstr.c b/test/tstmatchstr.c index e20cce8..bdb9751 100644 --- a/test/tstmatchstr.c +++ b/test/tstmatchstr.c @@ -1,60 +1,41 @@ -/* - * Copyright (C) 1995-2005, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2010 Index Data * See the file LICENSE for details. - * - * $Id: tstmatchstr.c,v 1.4 2005-06-25 15:46:07 adam Exp $ */ #include #include -#include - -struct { - char *s1; - char *s2; - int res; -} comp_strings[] = { - { "x", "x", 0 }, - { "x", "X", 0 }, - { "a", "b", 1 }, - { "b", "a", 1 }, - { "aa","a", 1 }, - { "a-", "a", 1 }, - { "A-b", "ab", 0}, - { "A--b", "ab", 1}, - { "A--b", "a-b", 1}, - { "A--b", "a--b", 0}, - { "a123", "a?", 0}, - {"a123", "a1.3", 0}, - {"a123", "..?", 0}, - {"a123", "a1.", 1}, - {"a123", "a...", 0}, - {0, 0, 0} }; +#include +#include int main (int argc, char **argv) { - int i; - for (i = 0; comp_strings[i].s1; i++) - { - int got = yaz_matchstr(comp_strings[i].s1,comp_strings[i].s2); - if (got > 0) - got = 1; - else if (got < 0) - got = -1; - if (got != comp_strings[i].res) - { - printf ("tststr %d got=%d res=%d\n", i, - got, comp_strings[i].res); - exit(1); - } - } - exit(0); + YAZ_CHECK_INIT(argc, argv); + + YAZ_CHECK(yaz_matchstr("x", "x") == 0); + YAZ_CHECK(yaz_matchstr("x", "X") == 0); + YAZ_CHECK(yaz_matchstr("a", "b") > 0); + YAZ_CHECK(yaz_matchstr("b", "a") > 0); + YAZ_CHECK(yaz_matchstr("aa","a") > 0); + YAZ_CHECK(yaz_matchstr("a-", "a") > 0); + YAZ_CHECK(yaz_matchstr("A-b", "ab") == 0); + YAZ_CHECK(yaz_matchstr("A--b", "ab") > 0); + YAZ_CHECK(yaz_matchstr("A--b", "a-b") > 0); + YAZ_CHECK(yaz_matchstr("A--b", "a--b") == 0); + YAZ_CHECK(yaz_matchstr("a123", "a?") == 0); + YAZ_CHECK(yaz_matchstr("a123", "a1.3") == 0); + YAZ_CHECK(yaz_matchstr("a123", "..?") == 0); + YAZ_CHECK(yaz_matchstr("a123", "a1.") > 0); + YAZ_CHECK(yaz_matchstr("a123", "a...") == 0); + + YAZ_CHECK_TERM; } /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab