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 struct conf_service *service = 0;
38 service = conf_service_create(4, 3, 0);
42 // expected metadata failures
43 YAZ_CHECK(!conf_service_add_metadata(0, 0, "service_needed",
44 Metadata_type_generic,
45 Metadata_merge_unique,
48 Metadata_mergekey_no));
50 YAZ_CHECK(!conf_service_add_metadata(service, -1, "out_of_bounds",
51 Metadata_type_generic,
52 Metadata_merge_unique,
55 Metadata_mergekey_no));
57 YAZ_CHECK(!conf_service_add_metadata(service, 4, "out_of_bounds",
58 Metadata_type_generic,
59 Metadata_merge_unique,
62 Metadata_mergekey_no));
64 YAZ_CHECK(!conf_service_add_metadata(service, 0, 0, //missing name
65 Metadata_type_generic,
66 Metadata_merge_unique,
69 Metadata_mergekey_no));
71 // expected metadata sucesses
72 YAZ_CHECK(conf_service_add_metadata(service, 0, "title",
73 Metadata_type_generic,
74 Metadata_merge_unique,
77 Metadata_mergekey_no));
79 YAZ_CHECK(conf_service_add_metadata(service, 1, "author",
80 Metadata_type_generic,
81 Metadata_merge_longest,
84 Metadata_mergekey_no));
86 YAZ_CHECK(conf_service_add_metadata(service, 2, "isbn",
91 Metadata_mergekey_no));
93 YAZ_CHECK(conf_service_add_metadata(service, 3, "year",
98 Metadata_mergekey_no));
101 // expected sortkey failures
102 YAZ_CHECK(!conf_service_add_sortkey(service, -1, "out_of_bounds",
103 Metadata_sortkey_skiparticle));
105 YAZ_CHECK(!conf_service_add_sortkey(service, -1, "out_of_bounds",
106 Metadata_sortkey_string));
108 YAZ_CHECK(!conf_service_add_sortkey(service, 3, "out_of_bounds",
109 Metadata_sortkey_relevance));
111 YAZ_CHECK(!conf_service_add_sortkey(service, 0, 0, //missing name
112 Metadata_sortkey_relevance));
115 // expected sortkey sucess
116 YAZ_CHECK(conf_service_add_sortkey(service, 0, "relevance",
117 Metadata_sortkey_relevance));
119 YAZ_CHECK(conf_service_add_sortkey(service, 1, "title",
120 Metadata_sortkey_string));
122 YAZ_CHECK(conf_service_add_sortkey(service, 2, "year",
123 Metadata_sortkey_numeric));
127 int main(int argc, char **argv)
129 YAZ_CHECK_INIT(argc, argv);
132 test_conf_service(argc, argv);
143 * c-file-style: "Stroustrup"
144 * indent-tabs-mode: nil
146 * vim: shiftwidth=4 tabstop=8 expandtab