X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftest_rpn2solr.c;h=a094225d927e31307f330e781e1805eea03b3090;hp=c7aa1e9d6f76ea35d0dbc93d5f0ab7f5dc64b56e;hb=030a9158c5c4991dba7b50de6b2f13f64177f99b;hpb=bb8c1303f5ffddd9dec1e3527f64fdaaa397698e diff --git a/test/test_rpn2solr.c b/test/test_rpn2solr.c index c7aa1e9..a094225 100644 --- a/test/test_rpn2solr.c +++ b/test/test_rpn2solr.c @@ -1,7 +1,10 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -50,15 +53,12 @@ static void tst1(void) YAZ_CHECK(compare(ct, "abc", "abc")); YAZ_CHECK(compare(ct, "\"a b c\"", "\"a b c\"")); -#if 0 -/* Invalid PQF, so this will never work */ - YAZ_CHECK(compare(ct, "a b", "a b")); -#endif 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, "@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 */ solr_transform_define_pattern(ct, "index.title", "1=4"); @@ -67,6 +67,30 @@ static void tst1(void) solr_transform_define_pattern(ct, "index.foo", "1=bar"); YAZ_CHECK(compare(ct, "@attr 1=bar abc", "foo:abc")); + /* 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=100 water", "water")); + YAZ_CHECK(compare(ct, "@attr 5=101 water", 0)); + YAZ_CHECK(compare(ct, "@attr 5=104 w#ter", "w?ter")); + YAZ_CHECK(compare(ct, "@attr 5=104 w#t?r", "w?t*r")); + YAZ_CHECK(compare(ct, "@attr 5=104 w#te?", "w?te*")); + YAZ_CHECK(compare(ct, "@attr 5=104 w\\#te?", "w?te*")); /* PQF eats # */ + YAZ_CHECK(compare(ct, "@attr 5=104 w\\\\#te?", "w#te*")); + + /* reserved characters */ + YAZ_CHECK(compare(ct, "@attr 5=104 \\\"\\\\\\\\", + "\\\"" "\\\\")); + YAZ_CHECK(compare(ct, "@attr 5=104 \\\"\\\\\\\\\\\"", + "\\\"" "\\\\" "\\\"")); + YAZ_CHECK(compare(ct, "@attr 5=104 \\\"\\\\", "\\\"\\\\")); + + YAZ_CHECK(compare(ct, "@attr 5=104 \\{:\\}", "\\{\\:\\}")); + + YAZ_CHECK(compare(ct, "@attr 5=104 \\\"\\\\\\\\\\\"", + "\\\"" "\\\\" "\\\"")); + solr_transform_close(ct); } @@ -81,7 +105,7 @@ static void tst2(void) wrbuf_puts(w, "/"); } wrbuf_puts(w, "../etc/pqf.properties"); - + ct = solr_transform_open_fname(wrbuf_cstr(w)); YAZ_CHECK(compare(ct, "@attr 1=4 abc", "dc.title:abc")); #if 0 @@ -90,14 +114,17 @@ static void tst2(void) YAZ_CHECK(compare(ct, "@attr 1=4 @attr 3=1 @attr 6=1 abc", "dc.title:abc")); YAZ_CHECK(compare(ct, "@attr 1=4 @attr 4=1 @attr 6=1 abc", "dc.title:abc")); -#if 0 + YAZ_CHECK(compare(ct, "@attr 1=1016 abc", "abc")); - YAZ_CHECK(compare(ct, "@attr 2=1 @attr 1=30 1980", "dc.date:[* to 1980]")); - YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=3 1980", "dc.date:1980")); - YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=5 1980", "dc.date:[* to 1980]")); - YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=2 1980", "dc.date:[* to 1980]")); - YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=4 1980", "dc.date:[1980 to *]")); + /* 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]")); + YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=3 1980", "dc.date:1980")); + YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=4 1980", "dc.date:[1980 TO *]")); +// YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=5 1980", "dc.date:[* TO 1980]")); + YAZ_CHECK(compare(ct, "@and @attr 1=30 @attr 2=4 234 @attr 1=30 @attr 2=2 1990", "dc.date:[234 TO *] AND dc.date:[* TO 1990]")); +#if 0 YAZ_CHECK(compare(ct, "@attr 2=103 @attr 1=_ALLRECORDS 1", "solr.allRecords=1")); #endif YAZ_CHECK(compare(ct, "@attr 1=500 abc", 0));