1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2009 Index Data
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <yaz/timing.h>
31 #include "pazpar2_config.h"
35 void test_conf_service(int argc, char **argv)
37 NMEM nmem = nmem_create();
39 struct conf_service *service = 0;
40 service = conf_service_create(nmem, 4, 3);
44 // expected metadata failures
45 YAZ_CHECK(!conf_service_add_metadata(0, service, 0, "dead_nmem",
46 Metadata_type_generic,
47 Metadata_merge_unique,
51 YAZ_CHECK(!conf_service_add_metadata(nmem, 0, 0, "service_needed",
52 Metadata_type_generic,
53 Metadata_merge_unique,
57 YAZ_CHECK(!conf_service_add_metadata(nmem, service, -1, "out_of_bounds",
58 Metadata_type_generic,
59 Metadata_merge_unique,
63 YAZ_CHECK(!conf_service_add_metadata(nmem, service, 4, "out_of_bounds",
64 Metadata_type_generic,
65 Metadata_merge_unique,
69 YAZ_CHECK(!conf_service_add_metadata(nmem, service, 0, 0, //missing name
70 Metadata_type_generic,
71 Metadata_merge_unique,
75 // expected metadata sucesses
76 YAZ_CHECK(conf_service_add_metadata(nmem, service, 0, "title",
77 Metadata_type_generic,
78 Metadata_merge_unique,
82 YAZ_CHECK(conf_service_add_metadata(nmem, service, 1, "author",
83 Metadata_type_generic,
84 Metadata_merge_longest,
88 YAZ_CHECK(conf_service_add_metadata(nmem, service, 2, "isbn",
94 YAZ_CHECK(conf_service_add_metadata(nmem, service, 3, "year",
101 // expected sortkey failures
102 YAZ_CHECK(!conf_service_add_sortkey(0, service, 0, "dead_nmem",
103 Metadata_sortkey_relevance));
105 YAZ_CHECK(!conf_service_add_sortkey(nmem, 0, 0, "service_neeeded",
106 Metadata_sortkey_numeric));
108 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, -1, "out_of_bounds",
109 Metadata_sortkey_skiparticle));
111 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, -1, "out_of_bounds",
112 Metadata_sortkey_string));
114 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, 3, "out_of_bounds",
115 Metadata_sortkey_relevance));
117 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, 0, 0, //missing name
118 Metadata_sortkey_relevance));
121 // expected sortkey sucess
122 YAZ_CHECK(conf_service_add_sortkey(nmem, service, 0, "relevance",
123 Metadata_sortkey_relevance));
125 YAZ_CHECK(conf_service_add_sortkey(nmem, service, 1, "title",
126 Metadata_sortkey_string));
128 YAZ_CHECK(conf_service_add_sortkey(nmem, service, 2, "year",
129 Metadata_sortkey_numeric));
139 //YAZ_CHECK_EQ(0, 1);
144 int main(int argc, char **argv)
146 YAZ_CHECK_INIT(argc, argv);
149 test_conf_service(argc, argv);
160 * indent-tabs-mode: nil
162 * vim: shiftwidth=4 tabstop=8 expandtab