CCL: And-list / sub-phrase split-out YAZ-844
[yaz-moved-to-github.git] / test / test_ccl.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
5 #if HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8
9 #include <string.h>
10 #include <yaz/ccl_xml.h>
11 #include <yaz/log.h>
12 #include <yaz/test.h>
13
14
15 static int tst_ccl_query(CCL_bibset bibset,
16                          const char *query,
17                          const char *result)
18 {
19     CCL_parser parser = ccl_parser_create(bibset);
20     int ret = 0;
21
22     if (parser && bibset)
23     {
24         struct ccl_rpn_node *rpn;
25
26         rpn = ccl_parser_find_str(parser, query);
27         if (rpn)
28         {
29             /* parse ok. check that result is there and match */
30             WRBUF wrbuf = wrbuf_alloc();
31             ccl_pquery(wrbuf, rpn);
32
33             /* check expect a result and that it matches */
34             if (result && !strcmp(wrbuf_cstr(wrbuf), result))
35                 ret = 1;
36             else
37             {
38                 yaz_log(YLOG_WARN, "%s: result does not match", query);
39                 yaz_log(YLOG_WARN, " expected %s", result);
40                 yaz_log(YLOG_WARN, " got      %s", wrbuf_cstr(wrbuf));
41                 ret = 0;
42             }
43             ccl_rpn_delete(rpn);
44             wrbuf_destroy(wrbuf);
45         }
46         else
47         {
48             if (result)
49             {
50                 yaz_log(YLOG_WARN, "%s: parse failed", query);
51                 ret = 0;
52             }
53             else
54                 ret = 1;
55         }
56     }
57     ccl_parser_destroy (parser);
58     return ret;
59 }
60
61 void tst1(int pass)
62 {
63     CCL_bibset bibset = ccl_qual_mk();
64     char tstline[128];
65
66     YAZ_CHECK(bibset);
67     if (!bibset)
68         return;
69
70     if (pass == 1)
71     {
72         CCL_bibset nbibset = ccl_qual_dup(bibset);
73         ccl_qual_rm(&bibset);
74         bibset = nbibset;
75     }
76
77     switch(pass)
78     {
79     case 0:
80         ccl_qual_fitem(bibset, "term dc.title", "comb");
81         ccl_qual_fitem(bibset, "u=4    s=pw t=l,r", "ti");
82         ccl_qual_fitem(bibset, "1=1016 s=al,pw t=r",    "term");
83         ccl_qual_fitem(bibset, "t=x", "reg");
84         ccl_qual_fitem(bibset, "t=z", "z");
85         ccl_qual_fitem(bibset, "1=/my/title",       "dc.title");
86         ccl_qual_fitem(bibset, "r=r,omiteq",        "date");
87         ccl_qual_fitem(bibset, "r=o",         "x");
88         ccl_qual_fitem(bibset, "dc.title", "title");
89         ccl_qual_fitem(bibset, "s=ag", "ag");
90         ccl_qual_fitem(bibset, "s=sl", "splitlist");
91         break;
92     case 1:
93         strcpy(tstline, "ti u=4    s=pw t=l,r");
94         ccl_qual_line(bibset, tstline);
95
96         strcpy(tstline, "term 1=1016 s=al,pw t=r  # default term");
97         ccl_qual_line(bibset, tstline);
98
99         strcpy(tstline, "reg t=x");
100         ccl_qual_line(bibset, tstline);
101
102         strcpy(tstline, "z t=z");
103         ccl_qual_line(bibset, tstline);
104
105         strcpy(tstline, "dc.title 1=/my/title");
106         ccl_qual_line(bibset, tstline);
107
108         strcpy(tstline, "date r=r,omiteq # ordered relation");
109         ccl_qual_line(bibset, tstline);
110
111         strcpy(tstline, "x r=o # ordered relation");
112         ccl_qual_line(bibset, tstline);
113
114         strcpy(tstline, "title dc.title # alias");
115         ccl_qual_line(bibset, tstline);
116
117         strcpy(tstline, "comb term dc.title # combination");
118         ccl_qual_line(bibset, tstline);
119
120         strcpy(tstline, "ag s=ag");
121         ccl_qual_line(bibset, tstline);
122
123         strcpy(tstline, "splitlist s=sl");
124         ccl_qual_line(bibset, tstline);
125         break;
126     case 2:
127         ccl_qual_buf(bibset, "ti u=4    s=pw t=l,r\n"
128                      "term 1=1016 s=al,pw t=r\r\n"
129                      "\n"
130                      "reg t=x\r\n"
131                      "z t=z\r\n"
132                      "dc.title 1=/my/title\n"
133                      "date r=r,omiteq\n"
134                      "x r=o\n"
135                      "title dc.title\n"
136                      "comb term dc.title\n"
137                      "ag s=ag\n"
138                      "splitlist s=sl\n"
139             );
140         break;
141     case 3:
142 #if YAZ_HAVE_XML2
143         if (1)
144         {
145             xmlDocPtr doc;
146             int r;
147             const char *addinfo = 0;
148             const char *xml_str =
149                 "<cclmap>\n"
150                 " <qual name=\"ti\">\n"
151                 "   <attr type=\"u\" value=\"4\"/>\n"
152                 "   <attr type=\"s\" value=\"pw\"/>\n"
153                 "   <attr type=\"t\" value=\"l,r\"/>\n"
154                 " </qual>\n"
155                 " <qual name=\"term\">\n"
156                 "   <attr type=\"1\" value=\"1016\"/>\n"
157                 "   <attr type=\"s\" value=\"al,pw\"/>\n"
158                 "   <attr type=\"t\" value=\"r\"/>\n"
159                 " </qual>\n"
160                 " <qual name=\"reg\">\n"
161                 "   <attr type=\"t\" value=\"x\"/>\n"
162                 " </qual>\n"
163                 " <qual name=\"z\">\n"
164                 "   <attr type=\"t\" value=\"z\"/>\n"
165                 " </qual>\n"
166                 " <qual name=\"dc.title\">\n"
167                 "   <attr type=\"1\" value=\"/my/title\"/>\n"
168                 " </qual>\n"
169                 " <qual name=\"date\">\n"
170                 "   <attr type=\"r\" value=\"r,omiteq\"/>\n"
171                 " </qual>\n"
172                 " <qual name=\"x\">\n"
173                 "   <attr type=\"r\" value=\"o\"/>\n"
174                 " </qual>\n"
175                 " <qual name=\"title\">\n"
176                 "   <qual name=\"dc.title\"/>\n"
177                 " </qual>\n"
178                 " <qual name=\"comb\">\n"
179                 "   <qual name=\"term\"/>\n"
180                 "   <qual name=\"dc.title\"/>\n"
181                 " </qual>\n"
182                 " <qual name=\"ag\">\n"
183                 "   <attr type=\"s\" value=\"ag\"/>\n"
184                 " </qual>\n"
185                 " <qual name=\"splitlist\">\n"
186                 "   <attr type=\"s\" value=\"sl\"/>\n"
187                 " </qual>\n"
188                 "</cclmap>\n";
189
190             doc = xmlParseMemory(xml_str, strlen(xml_str));
191             YAZ_CHECK(doc);
192
193             r = ccl_xml_config(bibset, xmlDocGetRootElement(doc), &addinfo);
194             YAZ_CHECK_EQ(r, 0);
195
196             xmlFreeDoc(doc);
197         }
198         break;
199 #else
200         return;
201 #endif
202     default:
203         YAZ_CHECK(0);
204         return;
205     }
206
207     YAZ_CHECK(tst_ccl_query(bibset, "x1", "@attr 4=2 @attr 1=1016 x1 "));
208
209     YAZ_CHECK(tst_ccl_query(bibset, "k\xc3\xb8" "benhavn", "@attr 4=2 @attr 1=1016 k\xc3\xb8" "benhavn "));
210
211     YAZ_CHECK(tst_ccl_query(bibset, "k\xf8" "benhavn", "@attr 4=2 @attr 1=1016 ""k\xf8" "benhavn "));
212
213     YAZ_CHECK(tst_ccl_query(bibset, "(((((x1)))))", "@attr 4=2 @attr 1=1016 x1 "));
214     YAZ_CHECK(tst_ccl_query(bibset, "x1 and x2",
215                   "@and "
216                   "@attr 4=2 @attr 1=1016 x1 "
217                   "@attr 4=2 @attr 1=1016 x2 "));
218     YAZ_CHECK(tst_ccl_query(bibset, "ti=x3", "@attr 4=2 @attr 1=4 x3 "));
219     YAZ_CHECK(tst_ccl_query(bibset, "dc.title=x4", "@attr 1=/my/title x4 "));
220     YAZ_CHECK(tst_ccl_query(bibset, "dc.title=(x4)", "@attr 1=/my/title x4 "));
221     YAZ_CHECK(tst_ccl_query(bibset, "x1 and", 0));
222     YAZ_CHECK(tst_ccl_query(bibset, "tix=x5", 0));
223
224     YAZ_CHECK(tst_ccl_query(bibset, "a%b",
225                   "@prox 0 1 0 2 k 2 "
226                   "@attr 4=2 @attr 1=1016 a "
227                   "@attr 4=2 @attr 1=1016 b "));
228     YAZ_CHECK(tst_ccl_query(bibset, "a%(b)",
229                   "@prox 0 1 0 2 k 2 "
230                   "@attr 4=2 @attr 1=1016 a "
231                   "@attr 4=2 @attr 1=1016 b "));
232     YAZ_CHECK(tst_ccl_query(bibset, "(a)%(b)",
233                   "@prox 0 1 0 2 k 2 "
234                   "@attr 4=2 @attr 1=1016 a "
235                   "@attr 4=2 @attr 1=1016 b "));
236     YAZ_CHECK(tst_ccl_query(bibset, "a%1b",
237                   "@prox 0 1 0 2 k 2 "
238                   "@attr 4=2 @attr 1=1016 a "
239                   "@attr 4=2 @attr 1=1016 b "));
240
241     YAZ_CHECK(tst_ccl_query(bibset, "a%2b",
242                   "@prox 0 2 0 2 k 2 "
243                   "@attr 4=2 @attr 1=1016 a "
244                   "@attr 4=2 @attr 1=1016 b "));
245
246     YAZ_CHECK(tst_ccl_query(bibset, "(a)%2(b)",
247                   "@prox 0 2 0 2 k 2 "
248                   "@attr 4=2 @attr 1=1016 a "
249                   "@attr 4=2 @attr 1=1016 b "));
250
251     YAZ_CHECK(tst_ccl_query(bibset, "a%19b",
252                   "@prox 0 19 0 2 k 2 "
253                   "@attr 4=2 @attr 1=1016 a "
254                   "@attr 4=2 @attr 1=1016 b "));
255
256     YAZ_CHECK(tst_ccl_query(bibset, "spid%æserne",
257                   "@prox 0 1 0 2 k 2 "
258                   "@attr 4=2 @attr 1=1016 spid "
259                   "@attr 4=2 @attr 1=1016 Ã¦serne "));
260
261     YAZ_CHECK(tst_ccl_query(bibset, "a!b",
262                   "@prox 0 1 1 2 k 2 "
263                   "@attr 4=2 @attr 1=1016 a "
264                   "@attr 4=2 @attr 1=1016 b "));
265     YAZ_CHECK(tst_ccl_query(bibset, "a!2b",
266                   "@prox 0 2 1 2 k 2 "
267                   "@attr 4=2 @attr 1=1016 a "
268                   "@attr 4=2 @attr 1=1016 b "));
269
270     YAZ_CHECK(tst_ccl_query(bibset, "a% (b or dc.title=c)",
271                             "@prox 0 1 0 2 k 2 "
272                             "@attr 4=2 @attr 1=1016 a "
273                             "@or @attr 4=2 @attr 1=1016 b "
274                             "@or @attr 4=2 @attr 1=/my/title c "
275                             "@attr 4=2 @attr 1=1016 c "
276     ));
277
278     YAZ_CHECK(tst_ccl_query(bibset, "(a b) % (c)",
279                             "@prox 0 1 0 2 k 2 @and "
280                             "@attr 4=2 @attr 1=1016 a @attr 4=2 @attr 1=1016 b "
281                             "@attr 4=2 @attr 1=1016 c " ));
282
283     YAZ_CHECK(tst_ccl_query(bibset, "date=1980",
284                             "1980 "));
285     YAZ_CHECK(tst_ccl_query(bibset, "(date=1980)",
286                             "1980 "));
287     YAZ_CHECK(tst_ccl_query(bibset, "date>1980",
288                             "@attr 2=5 1980 "));
289     YAZ_CHECK(tst_ccl_query(bibset, "date>=1980",
290                             "@attr 2=4 1980 "));
291     YAZ_CHECK(tst_ccl_query(bibset, "date<1980",
292                             "@attr 2=1 1980 "));
293     YAZ_CHECK(tst_ccl_query(bibset, "date<=1980",
294                             "@attr 2=2 1980 "));
295     YAZ_CHECK(tst_ccl_query(bibset, "date=234-1990",
296                             "@and @attr 2=4 234 @attr 2=2 1990 "));
297     YAZ_CHECK(tst_ccl_query(bibset, "date=234- 1990",
298                             "@and @attr 2=4 234 @attr 2=2 1990 "));
299     YAZ_CHECK(tst_ccl_query(bibset, "date=234 -1990",
300                             "@and @attr 2=4 234 @attr 2=2 1990 "));
301     YAZ_CHECK(tst_ccl_query(bibset, "date=234 - 1990",
302                             "@and @attr 2=4 234 @attr 2=2 1990 "));
303     YAZ_CHECK(tst_ccl_query(bibset, "date=-1980",
304                             "@attr 2=2 1980 "));
305     YAZ_CHECK(tst_ccl_query(bibset, "date=- 1980",
306                             "@attr 2=2 1980 "));
307     YAZ_CHECK(tst_ccl_query(bibset, "x=-1980",
308                             "@attr 2=3 -1980 "));
309     YAZ_CHECK(tst_ccl_query(bibset, "x=- 1980",
310                             "@attr 2=2 1980 "));
311     YAZ_CHECK(tst_ccl_query(bibset, "x= -1980",
312                             "@attr 2=3 -1980 "));
313     YAZ_CHECK(tst_ccl_query(bibset, "x=234-1990",
314                             "@attr 2=3 234-1990 "));
315     YAZ_CHECK(tst_ccl_query(bibset, "x=234 - 1990",
316                             "@and @attr 2=4 234 @attr 2=2 1990 "));
317     YAZ_CHECK(tst_ccl_query(bibset, "ti=a,b",
318                             "@attr 4=1 @attr 1=4 a,b "));
319     YAZ_CHECK(tst_ccl_query(bibset, "ti=a, b",
320                             "@attr 4=1 @attr 1=4 \"a, b\" "));
321     YAZ_CHECK(tst_ccl_query(bibset, "ti=a-b",
322                             "@attr 4=2 @attr 1=4 a-b "));
323     YAZ_CHECK(tst_ccl_query(bibset, "ti=a - b",
324                             "@attr 4=1 @attr 1=4 \"a - b\" "));
325
326     YAZ_CHECK(tst_ccl_query(bibset, "a?",
327                             "@attr 5=1 @attr 4=2 @attr 1=1016 a "));
328     YAZ_CHECK(tst_ccl_query(bibset, "a b",
329                             "@and @attr 4=2 @attr 1=1016 a "
330                             "@attr 4=2 @attr 1=1016 b "));
331
332     YAZ_CHECK(tst_ccl_query(bibset, "a b?",
333                             "@and @attr 4=2 @attr 1=1016 a "
334                             "@attr 5=1 @attr 4=2 @attr 1=1016 b "));
335
336     YAZ_CHECK(tst_ccl_query(bibset, "title=a",
337                             "@attr 1=/my/title a "));
338
339     YAZ_CHECK(tst_ccl_query(bibset, "reg=a?b#\"c?\"",
340                             "@attr 5=102 a.*b.c\\\\? "));
341     YAZ_CHECK(tst_ccl_query(bibset, "z=a?b#\"c?\"",
342                             "@attr 5=104 a?b#c\\\\? "));
343
344     YAZ_CHECK(tst_ccl_query(bibset, "reg=\\(",
345                             "( "));
346     YAZ_CHECK(tst_ccl_query(bibset, "z=\\(",
347                             "( "));
348
349     YAZ_CHECK(tst_ccl_query(bibset, "z=a b#",
350                             "@attr 5=104 \"a b#\" "));
351
352     YAZ_CHECK(tst_ccl_query(bibset, "reg=\\\"",
353                             "\"\\\"\" "));
354     YAZ_CHECK(tst_ccl_query(bibset, "z=\\\"",
355                             "\"\\\"\" "));
356
357     YAZ_CHECK(tst_ccl_query(bibset, "reg=.",
358                             ". "));
359     YAZ_CHECK(tst_ccl_query(bibset, "z=.",
360                             ". "));
361
362     YAZ_CHECK(tst_ccl_query(bibset, "reg=\".\"",
363                             ". "));
364     YAZ_CHECK(tst_ccl_query(bibset, "z=\".\"",
365                             ". "));
366
367     YAZ_CHECK(tst_ccl_query(bibset, "reg=?\\?",
368                             "@attr 5=102 .*\\\\? "));
369     YAZ_CHECK(tst_ccl_query(bibset, "z=?\\?",
370                             "@attr 5=104 ?\\\\? "));
371
372     YAZ_CHECK(tst_ccl_query(bibset, "reg=\"?\\?\"",
373                             "?? "));
374     YAZ_CHECK(tst_ccl_query(bibset, "z=\"?\\?\"",
375                             "?? "));
376
377     YAZ_CHECK(tst_ccl_query(bibset, "reg=\\\\",
378                             "\\\\ "));
379     YAZ_CHECK(tst_ccl_query(bibset, "z=\\\\",
380                             "\\\\ "));
381
382     YAZ_CHECK(tst_ccl_query(bibset, "\\\\",
383                             "@attr 4=2 @attr 1=1016 \\\\ "));
384
385     YAZ_CHECK(tst_ccl_query(bibset, "comb=a",
386                             "@or @attr 4=2 @attr 1=1016 a "
387                             "@attr 1=/my/title a "));
388
389     YAZ_CHECK(tst_ccl_query(bibset, "a? b?",
390                             "@and @attr 5=1 @attr 4=2 @attr 1=1016 a "
391                             "@attr 5=1 @attr 4=2 @attr 1=1016 b "));
392
393     YAZ_CHECK(tst_ccl_query(bibset, "\"a\"? \"b?\"",
394                             "@and @attr 5=1 @attr 4=2 @attr 1=1016 a "
395                             "@attr 4=2 @attr 1=1016 b? "));
396
397     YAZ_CHECK(tst_ccl_query(bibset, "@and",
398                             "@attr 4=2 @attr 1=1016 \\@and "));
399
400     YAZ_CHECK(tst_ccl_query(bibset, "a@and",
401                             "@attr 4=2 @attr 1=1016 a@and "));
402
403     YAZ_CHECK(tst_ccl_query(bibset, "}",
404                             "@attr 4=2 @attr 1=1016 } "));
405
406     YAZ_CHECK(tst_ccl_query(bibset, "{",
407                             "@attr 4=2 @attr 1=1016 \"{\" "));
408
409     YAZ_CHECK(tst_ccl_query(bibset, "\"a b c\"",
410                             "@attr 4=1 @attr 1=1016 \"a b c\" "));
411
412     YAZ_CHECK(tst_ccl_query(bibset, "\"a b  c  \"",
413                             "@attr 4=1 @attr 1=1016 \"a b  c  \" "));
414
415     YAZ_CHECK(tst_ccl_query(bibset, "ag=a",
416                             "@attr 4=2 a "));
417
418     YAZ_CHECK(tst_ccl_query(bibset, "ag=a b",
419                             "@attr 4=2 \"a b\" "));
420
421     YAZ_CHECK(tst_ccl_query(bibset, "ag=a b \"c d\"",
422                             "@and @attr 4=2 \"a b\" @attr 4=1 \"c d\" "));
423
424     YAZ_CHECK(tst_ccl_query(bibset, "ag=a b \"c\"",
425                             "@attr 4=2 \"a b c\" "));
426
427     YAZ_CHECK(tst_ccl_query(bibset, "ag=a b \"\"",
428                             "@attr 4=2 \"a b \" "));
429
430     YAZ_CHECK(tst_ccl_query(bibset, "ag=a \"b c\" d",
431                             "@and @and "
432                             "@attr 4=2 a @attr 4=1 \"b c\" @attr 4=2 d "));
433
434     YAZ_CHECK(tst_ccl_query(bibset, "ag=\"a b c\"",
435                             "@attr 4=1 \"a b c\" "));
436
437     YAZ_CHECK(tst_ccl_query(bibset, "ag=\"a b c\" \"d e\"",
438                             "@and @attr 4=1 \"a b c\" @attr 4=1 \"d e\" "));
439
440     YAZ_CHECK(tst_ccl_query(bibset, "splitlist=a", "a "));
441     YAZ_CHECK(tst_ccl_query(bibset, "splitlist=a b", "@or "
442                             "@and a b \"a b\" "));
443     YAZ_CHECK(tst_ccl_query(bibset, "splitlist=a b c", "@or @or @or "
444                             "@and @and a b c "
445                             "@and a \"b c\" "
446                             "@and \"a b\" c "
447                             "\"a b c\" "));
448     ccl_qual_rm(&bibset);
449 }
450
451 void tst2(void)
452 {
453     CCL_bibset bibset = ccl_qual_mk();
454
455     YAZ_CHECK(bibset);
456     if (!bibset)
457         return;
458
459     ccl_qual_fitem(bibset, "u=4    s=pw t=l,r", "ti");
460     ccl_qual_fitem(bibset, "1=1016 s=al,pw t=z",    "term");
461
462     YAZ_CHECK(tst_ccl_query(bibset, "a?#",
463                             "@attr 5=104 @attr 4=2 @attr 1=1016 a?# "));
464
465     YAZ_CHECK(tst_ccl_query(bibset, "a b?#",
466                             "@and @attr 4=2 @attr 1=1016 a @attr 5=104 @attr 4=2 @attr 1=1016 b?# "));
467
468     YAZ_CHECK(tst_ccl_query(bibset, "a*",
469                             "@attr 4=2 @attr 1=1016 a* "));
470
471     YAZ_CHECK(tst_ccl_query(bibset, "a?",
472                             "@attr 5=104 @attr 4=2 @attr 1=1016 a? "));
473
474     ccl_qual_fitem(bibset, "*", "@truncation");
475     YAZ_CHECK(tst_ccl_query(bibset, "a*",
476                             "@attr 5=104 @attr 4=2 @attr 1=1016 a? "));
477
478     YAZ_CHECK(tst_ccl_query(bibset, "a?",
479                             "@attr 4=2 @attr 1=1016 a? "));
480
481     ccl_qual_fitem(bibset, "?", "@mask");
482     YAZ_CHECK(tst_ccl_query(bibset, "a?",
483                             "@attr 5=104 @attr 4=2 @attr 1=1016 a# "));
484
485
486     ccl_qual_fitem(bibset, "", "@mask");
487     ccl_qual_fitem(bibset, "", "@truncation");
488     YAZ_CHECK(tst_ccl_query(bibset, "a?#",
489                             "@attr 4=2 @attr 1=1016 a?# "));
490
491     ccl_qual_fitem(bibset, "og", "@and");
492     ccl_qual_fitem(bibset, "eller", "@or");
493     ccl_qual_fitem(bibset, "ikke", "@not");
494
495     YAZ_CHECK(tst_ccl_query(bibset, "a og b eller c ikke d",
496                             "@not @or @and @attr 4=2 @attr 1=1016 a "
497                             "@attr 4=2 @attr 1=1016 b "
498                             "@attr 4=2 @attr 1=1016 c "
499                             "@attr 4=2 @attr 1=1016 d "));
500     ccl_qual_rm(&bibset);
501 }
502
503
504 void tst_addinfo(void)
505 {
506     const char *addinfo;
507     int r;
508     CCL_bibset bibset = ccl_qual_mk();
509
510     r = ccl_qual_fitem2(bibset, "u=4    s=pw t=l,r", "ti", &addinfo);
511     YAZ_CHECK(r == 0 && addinfo == 0);
512
513     r = ccl_qual_fitem2(bibset, "1=1016 s=al,pw t=z", "term", &addinfo);
514     YAZ_CHECK(r == 0 && addinfo == 0);
515
516     r = ccl_qual_fitem2(bibset, "x=", "term", &addinfo);
517     YAZ_CHECK(r != 0 && addinfo != 0);
518
519     r = ccl_qual_fitem2(bibset, "12=3", "term", &addinfo);
520     YAZ_CHECK(r == 0 && addinfo == 0);
521
522     r = ccl_qual_fitem2(bibset, "ab=3", "term", &addinfo);
523     YAZ_CHECK(r != 0 && addinfo != 0);
524
525     r = ccl_qual_fitem2(bibset, "x=ab", "term", &addinfo);
526     YAZ_CHECK(r != 0 && addinfo != 0);
527
528     r = ccl_qual_fitem2(bibset, "s=ab", "term", &addinfo);
529     YAZ_CHECK(r == 0 && addinfo == 0);
530
531     ccl_qual_rm(&bibset);
532 }
533
534 int main(int argc, char **argv)
535 {
536     YAZ_CHECK_INIT(argc, argv);
537     YAZ_CHECK_LOG();
538     tst1(0);
539     tst1(1);
540     tst1(2);
541     tst1(3);
542     tst2();
543     tst_addinfo();
544     YAZ_CHECK_TERM;
545 }
546 /*
547  * Local variables:
548  * c-basic-offset: 4
549  * c-file-style: "Stroustrup"
550  * indent-tabs-mode: nil
551  * End:
552  * vim: shiftwidth=4 tabstop=8 expandtab
553  */
554