1 /* $Id: test_config.c,v 1.4 2007-07-30 23:16:33 quinn Exp $
2 Copyright (c) 2006-2007, Index Data.
4 This file is part of Pazpar2.
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
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
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
28 #include <yaz/timing.h>
37 void test_conf_service(int argc, char **argv)
39 NMEM nmem = nmem_create();
41 struct conf_service *service = 0;
42 service = conf_service_create(nmem, 4, 3);
46 // expected metadata failures
47 YAZ_CHECK(!conf_service_add_metadata(0, service, 0, "dead_nmem",
48 Metadata_type_generic,
49 Metadata_merge_unique,
53 YAZ_CHECK(!conf_service_add_metadata(nmem, 0, 0, "service_needed",
54 Metadata_type_generic,
55 Metadata_merge_unique,
59 YAZ_CHECK(!conf_service_add_metadata(nmem, service, -1, "out_of_bounds",
60 Metadata_type_generic,
61 Metadata_merge_unique,
65 YAZ_CHECK(!conf_service_add_metadata(nmem, service, 4, "out_of_bounds",
66 Metadata_type_generic,
67 Metadata_merge_unique,
71 YAZ_CHECK(!conf_service_add_metadata(nmem, service, 0, 0, //missing name
72 Metadata_type_generic,
73 Metadata_merge_unique,
77 // expected metadata sucesses
78 YAZ_CHECK(conf_service_add_metadata(nmem, service, 0, "title",
79 Metadata_type_generic,
80 Metadata_merge_unique,
84 YAZ_CHECK(conf_service_add_metadata(nmem, service, 1, "author",
85 Metadata_type_generic,
86 Metadata_merge_longest,
90 YAZ_CHECK(conf_service_add_metadata(nmem, service, 2, "isbn",
96 YAZ_CHECK(conf_service_add_metadata(nmem, service, 3, "year",
103 // expected sortkey failures
104 YAZ_CHECK(!conf_service_add_sortkey(0, service, 0, "dead_nmem",
105 Metadata_sortkey_relevance));
107 YAZ_CHECK(!conf_service_add_sortkey(nmem, 0, 0, "service_neeeded",
108 Metadata_sortkey_numeric));
110 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, -1, "out_of_bounds",
111 Metadata_sortkey_skiparticle));
113 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, -1, "out_of_bounds",
114 Metadata_sortkey_string));
116 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, 3, "out_of_bounds",
117 Metadata_sortkey_relevance));
119 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, 0, 0, //missing name
120 Metadata_sortkey_relevance));
123 // expected sortkey sucess
124 YAZ_CHECK(conf_service_add_sortkey(nmem, service, 0, "relevance",
125 Metadata_sortkey_relevance));
127 YAZ_CHECK(conf_service_add_sortkey(nmem, service, 1, "title",
128 Metadata_sortkey_string));
130 YAZ_CHECK(conf_service_add_sortkey(nmem, service, 2, "year",
131 Metadata_sortkey_numeric));
141 //YAZ_CHECK_EQ(0, 1);
146 int main(int argc, char **argv)
148 YAZ_CHECK_INIT(argc, argv);
151 test_conf_service(argc, argv);
162 * indent-tabs-mode: nil
164 * vim: shiftwidth=4 tabstop=8 expandtab