X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftstmatchstr.c;fp=test%2Ftstmatchstr.c;h=6f5c14ce96904f3e733559ef7f3170f01c972196;hb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9;hp=0000000000000000000000000000000000000000;hpb=c71d717ada2a9ef730d527f161eb5ba9aa641a9f;p=yaz-moved-to-github.git diff --git a/test/tstmatchstr.c b/test/tstmatchstr.c new file mode 100644 index 0000000..6f5c14c --- /dev/null +++ b/test/tstmatchstr.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2002-2003, Index Data + * See the file LICENSE for details. + * + * $Id: tstmatchstr.c,v 1.1 2003-10-27 12:21:38 adam Exp $ + */ + +#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} }; + +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); +} +