X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftest_sortspec.c;h=7af40265c73fc93956e20ca5327cfc33d14ff0f4;hp=516c372b211d9fbf2f7ad9d43dfbab0af7e6343c;hb=fd0e844569539b1c365114ff1b82209832f14bf7;hpb=9d74b82276b2e844ffe8b9f59763da62d877e3a7 diff --git a/test/test_sortspec.c b/test/test_sortspec.c index 516c372..7af4026 100644 --- a/test/test_sortspec.c +++ b/test/test_sortspec.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2012 Index Data + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. */ #if HAVE_CONFIG_H @@ -163,12 +163,12 @@ static int solr_sortkeys(const char *arg, const char *expected_result) { -static int check_srw_sortkeys_to_sort_spec(const char *arg, - const char *expected_result) +static int check_sortkeys_to_sort_spec(const char *arg, + const char *expected_result, int (*sort_strategy)(const char *, WRBUF)) { WRBUF w = wrbuf_alloc(); int ret = 0; - int r = yaz_srw_sortkeys_to_sort_spec(arg, w); + int r = sort_strategy(arg, w); if (!expected_result && r) ret = 1; @@ -199,6 +199,13 @@ static int check_srw_sortkeys_to_sort_spec(const char *arg, return ret; } +static int check_srw_sortkeys_to_sort_spec(const char *arg, const char *expected_result) { + return check_sortkeys_to_sort_spec(arg, expected_result, yaz_srw_sortkeys_to_sort_spec); +} + +static int check_solr_sortkeys_to_sort_spec(const char *arg, const char *expected_result) { + return check_sortkeys_to_sort_spec(arg, expected_result, yaz_solr_sortkeys_to_sort_spec); +} static void tst(void) { @@ -236,8 +243,14 @@ static void tst(void) YAZ_CHECK(solr_sortkeys("title a", "title asc")); YAZ_CHECK(solr_sortkeys("title a date ds", - "title asc, date desc")); + "title asc" + ",date desc")); YAZ_CHECK(solr_sortkeys("1=4,2=3 a", 0)); + + YAZ_CHECK(check_solr_sortkeys_to_sort_spec( + "date asc", + "date ai")); + } int main(int argc, char **argv)