From f48fb0d2637f96e6f8e1824201da71213dbc6928 Mon Sep 17 00:00:00 2001 From: Dennis Schafroth Date: Mon, 1 Oct 2012 16:13:35 +0200 Subject: [PATCH] Add test for native sorting in Solr. ASSIGNED - issue YAZ-617: Implement native Sorting for solr https://jira.indexdata.com/browse/YAZ-617 --- test/test_sortspec.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/test_sortspec.c b/test/test_sortspec.c index 516c372..fe4d9ab 100644 --- a/test/test_sortspec.c +++ b/test/test_sortspec.c @@ -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) -- 1.7.10.4