added interface for adding sort parameters for record lists, use like this
[pazpar2-moved-to-github.git] / src / test_reclists.c
1 /* $Id: test_reclists.c,v 1.1 2007-04-25 13:09:17 marc Exp $
2    Copyright (c) 2006-2007, Index Data.
3
4 This file is part of Pazpar2.
5
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #if HAVE_CONFIG_H
23 #include "cconfig.h"
24 #endif
25
26 #define USE_TIMING 0
27 #if USE_TIMING
28 #include <yaz/timing.h>
29 #endif
30
31 #include <yaz/test.h>
32
33
34 #include "config.h"
35 //#include "record.h"
36 #include "reclists.h"
37
38
39 void test_reclist_sortparms(int argc, char **argv)
40 {
41   NMEM  nmem = nmem_create();
42
43   struct conf_service *service = 0; 
44   service =  conf_service_create(nmem, 1, 2);
45
46   conf_service_add_metadata(nmem, service, 0, "title",
47                             Metadata_type_generic, Metadata_merge_unique,
48                             1, 1, 1, 0);
49
50   conf_service_add_sortkey(nmem, service, 0, "relevance",
51                            Metadata_sortkey_relevance);
52   
53   conf_service_add_sortkey(nmem, service, 1, "title",
54                            Metadata_sortkey_string);
55   
56
57   // initializing of sort parameters is controlled by service descriptions
58   struct reclist_sortparms *sort_parms = 0;
59
60   // sorting ascending according to relevance, then title
61   YAZ_CHECK(0 == sort_parms);
62   YAZ_CHECK(reclist_sortparms_insert(nmem, &sort_parms, service, "title", 1));
63   YAZ_CHECK(sort_parms);
64
65   YAZ_CHECK(0 == sort_parms->next);
66   YAZ_CHECK(reclist_sortparms_insert(nmem, &sort_parms, service, 
67                                      "relevance", 1));
68   YAZ_CHECK(sort_parms->next);
69
70
71   nmem_destroy(nmem);
72
73   //YAZ_CHECK(0 == 0);
74   //YAZ_CHECK_EQ(0, 1);
75 }
76
77
78 int main(int argc, char **argv)
79 {
80     YAZ_CHECK_INIT(argc, argv); 
81     YAZ_CHECK_LOG(); 
82
83
84     test_reclist_sortparms(argc, argv); 
85
86     
87     YAZ_CHECK_TERM;
88 }
89
90
91
92
93 /*
94  * Local variables:
95  * c-basic-offset: 4
96  * indent-tabs-mode: nil
97  * End:
98  * vim: shiftwidth=4 tabstop=8 expandtab
99  */