1 /* $Id: test_config.c,v 1.1 2007-04-19 19:42:30 marc 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
27 #include <sys/socket.h>
39 #include <yaz/timing.h>
45 //#include "pazpar2.h"
50 void test_conf_service(int argc, char **argv)
52 NMEM nmem = nmem_create();
54 struct conf_service *service = 0;
55 service = conf_service_create(nmem, 4, 1);
59 // expected metadata failures
60 YAZ_CHECK(!conf_service_add_metadata(0, service, 0, "dead_nmem",
61 Metadata_type_generic,
62 Metadata_merge_unique,
65 YAZ_CHECK(!conf_service_add_metadata(nmem, 0, 0, "service_needed",
66 Metadata_type_generic,
67 Metadata_merge_unique,
70 YAZ_CHECK(!conf_service_add_metadata(nmem, service, -1, "out_of_bounds",
71 Metadata_type_generic,
72 Metadata_merge_unique,
75 YAZ_CHECK(!conf_service_add_metadata(nmem, service, 4, "out_of_bounds",
76 Metadata_type_generic,
77 Metadata_merge_unique,
80 YAZ_CHECK(!conf_service_add_metadata(nmem, service, 0, 0, //missing name
81 Metadata_type_generic,
82 Metadata_merge_unique,
85 // expected metadata sucesses
86 YAZ_CHECK(conf_service_add_metadata(nmem, service, 0, "title",
87 Metadata_type_generic,
88 Metadata_merge_unique,
91 YAZ_CHECK(conf_service_add_metadata(nmem, service, 1, "author",
92 Metadata_type_generic,
93 Metadata_merge_longest,
96 YAZ_CHECK(conf_service_add_metadata(nmem, service, 2, "isbn",
101 YAZ_CHECK(conf_service_add_metadata(nmem, service, 3, "year",
103 Metadata_merge_range,
107 // expected sortkey failures
108 YAZ_CHECK(!conf_service_add_sortkey(0, service, 0, "dead_nmem",
109 Metadata_sortkey_relevance));
111 YAZ_CHECK(!conf_service_add_sortkey(nmem, 0, 0, "service_neeeded",
112 Metadata_sortkey_numeric));
114 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, -1, "out_of_bounds",
115 Metadata_sortkey_skiparticle));
117 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, -1, "out_of_bounds",
118 Metadata_sortkey_string));
120 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, 1, "out_of_bounds",
121 Metadata_sortkey_relevance));
123 YAZ_CHECK(!conf_service_add_sortkey(nmem, service, 0, 0, //missing name
124 Metadata_sortkey_relevance));
127 // expected sortkey sucess
128 YAZ_CHECK(conf_service_add_sortkey(nmem, service, 0, "title",
129 Metadata_sortkey_relevance));
138 //YAZ_CHECK_EQ(0, 1);
143 int main(int argc, char **argv)
145 YAZ_CHECK_INIT(argc, argv);
148 test_conf_service(argc, argv);
159 * indent-tabs-mode: nil
161 * vim: shiftwidth=4 tabstop=8 expandtab