X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftest_rpn2solr.c;h=62c2d510c06393e1b2d7b35759dae5d8dd6ff151;hp=3589e7fd26e822744fbb7855855bb0e4c95c24ed;hb=800e0637cfe783fa9966e11712b7e20023ba2245;hpb=af3536cd462cf09e507f2656dc3f1101bc78ea75 diff --git a/test/test_rpn2solr.c b/test/test_rpn2solr.c index 3589e7f..62c2d51 100644 --- a/test/test_rpn2solr.c +++ b/test/test_rpn2solr.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ #if HAVE_CONFIG_H @@ -39,7 +39,10 @@ static int compare(solr_transform_t ct, const char *pqf, const char *solr) if (solr && !strcmp(wrbuf_cstr(w), solr)) ret = 1; else - yaz_log(YLOG_LOG, "Exp: %s", solr); + { + yaz_log(YLOG_WARN, " expected: %s", solr ? solr : "null"); + yaz_log(YLOG_WARN, " got: %s", wrbuf_cstr(w)); + } } } wrbuf_destroy(w); @@ -51,12 +54,19 @@ static void tst1(void) { solr_transform_t ct = solr_transform_create(); + YAZ_CHECK(compare(ct, "@or a @and b c", "a OR (b AND c)")); YAZ_CHECK(compare(ct, "abc", "abc")); YAZ_CHECK(compare(ct, "\"a b c\"", "\"a b c\"")); + YAZ_CHECK(compare(ct, "\"\"", "\"\"")); YAZ_CHECK(compare(ct, "@not a b", "a AND NOT b")); YAZ_CHECK(compare(ct, "@and @or a b c", "(a OR b) AND c")); YAZ_CHECK(compare(ct, "@and a b", "a AND b")); YAZ_CHECK(compare(ct, "@or a b", "a OR b")); + YAZ_CHECK(compare(ct, "@or a @and b c", "a OR (b AND c)")); + YAZ_CHECK(compare(ct, "@or @and a b @and c d", "(a AND b) OR (c AND d)")); + YAZ_CHECK(compare(ct, "@or @or a b @or c d", "(a OR b) OR (c OR d)")); + YAZ_CHECK(compare(ct, "@or @or @or a b @or c d @or e f", "((a OR b) OR (c OR d)) OR (e OR f)")); + YAZ_CHECK(compare(ct, "@and @and a b @and c d", "(a AND b) AND (c AND d)")); YAZ_CHECK(compare(ct, "@attr 1=field abc", "field:abc")); YAZ_CHECK(compare(ct, "@attr 1=field \"a b c\"", "field:\"a b c\"")); YAZ_CHECK(compare(ct, "@attr 1=4 abc", 0)); /* should fail */ @@ -69,8 +79,8 @@ static void tst1(void) /* Truncation */ YAZ_CHECK(compare(ct, "@attr 5=1 water", "water*")); - YAZ_CHECK(compare(ct, "@attr 5=2 water", 0)); - YAZ_CHECK(compare(ct, "@attr 5=3 water", 0)); + YAZ_CHECK(compare(ct, "@attr 5=2 water", "*water")); + YAZ_CHECK(compare(ct, "@attr 5=3 water", "*water*")); YAZ_CHECK(compare(ct, "@attr 5=100 water", "water")); YAZ_CHECK(compare(ct, "@attr 5=101 water", 0)); YAZ_CHECK(compare(ct, "@attr 5=104 w#ter", "w?ter")); @@ -134,7 +144,6 @@ static void tst2(void) YAZ_CHECK(compare(ct, "@attr 1=4 @attr 4=1 @attr 6=1 abc", "dc.title:abc")); YAZ_CHECK(compare(ct, "@attr 1=1016 abc", "abc")); - /* Date check */ YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=1 1980", "dc.date:[* TO 1980}")); YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=2 1980", "dc.date:[* TO 1980]"));