CCL: split-list deals with use attr 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 u=2", "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 u=2");
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 u=2\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                 "   <attr type=\"u\" value=\"2\"/>\n"
188                 " </qual>\n"
189                 "</cclmap>\n";
190
191             doc = xmlParseMemory(xml_str, strlen(xml_str));
192             YAZ_CHECK(doc);
193
194             r = ccl_xml_config(bibset, xmlDocGetRootElement(doc), &addinfo);
195             YAZ_CHECK_EQ(r, 0);
196
197             xmlFreeDoc(doc);
198         }
199         break;
200 #else
201         return;
202 #endif
203     default:
204         YAZ_CHECK(0);
205         return;
206     }
207
208     YAZ_CHECK(tst_ccl_query(bibset, "x1", "@attr 4=2 @attr 1=1016 x1 "));
209
210     YAZ_CHECK(tst_ccl_query(bibset, "k\xc3\xb8" "benhavn", "@attr 4=2 @attr 1=1016 k\xc3\xb8" "benhavn "));
211
212     YAZ_CHECK(tst_ccl_query(bibset, "k\xf8" "benhavn", "@attr 4=2 @attr 1=1016 ""k\xf8" "benhavn "));
213
214     YAZ_CHECK(tst_ccl_query(bibset, "(((((x1)))))", "@attr 4=2 @attr 1=1016 x1 "));
215     YAZ_CHECK(tst_ccl_query(bibset, "x1 and x2",
216                   "@and "
217                   "@attr 4=2 @attr 1=1016 x1 "
218                   "@attr 4=2 @attr 1=1016 x2 "));
219     YAZ_CHECK(tst_ccl_query(bibset, "ti=x3", "@attr 4=2 @attr 1=4 x3 "));
220     YAZ_CHECK(tst_ccl_query(bibset, "dc.title=x4", "@attr 1=/my/title x4 "));
221     YAZ_CHECK(tst_ccl_query(bibset, "dc.title=(x4)", "@attr 1=/my/title x4 "));
222     YAZ_CHECK(tst_ccl_query(bibset, "x1 and", 0));
223     YAZ_CHECK(tst_ccl_query(bibset, "tix=x5", 0));
224
225     YAZ_CHECK(tst_ccl_query(bibset, "a%b",
226                   "@prox 0 1 0 2 k 2 "
227                   "@attr 4=2 @attr 1=1016 a "
228                   "@attr 4=2 @attr 1=1016 b "));
229     YAZ_CHECK(tst_ccl_query(bibset, "a%(b)",
230                   "@prox 0 1 0 2 k 2 "
231                   "@attr 4=2 @attr 1=1016 a "
232                   "@attr 4=2 @attr 1=1016 b "));
233     YAZ_CHECK(tst_ccl_query(bibset, "(a)%(b)",
234                   "@prox 0 1 0 2 k 2 "
235                   "@attr 4=2 @attr 1=1016 a "
236                   "@attr 4=2 @attr 1=1016 b "));
237     YAZ_CHECK(tst_ccl_query(bibset, "a%1b",
238                   "@prox 0 1 0 2 k 2 "
239                   "@attr 4=2 @attr 1=1016 a "
240                   "@attr 4=2 @attr 1=1016 b "));
241
242     YAZ_CHECK(tst_ccl_query(bibset, "a%2b",
243                   "@prox 0 2 0 2 k 2 "
244                   "@attr 4=2 @attr 1=1016 a "
245                   "@attr 4=2 @attr 1=1016 b "));
246
247     YAZ_CHECK(tst_ccl_query(bibset, "(a)%2(b)",
248                   "@prox 0 2 0 2 k 2 "
249                   "@attr 4=2 @attr 1=1016 a "
250                   "@attr 4=2 @attr 1=1016 b "));
251
252     YAZ_CHECK(tst_ccl_query(bibset, "a%19b",
253                   "@prox 0 19 0 2 k 2 "
254                   "@attr 4=2 @attr 1=1016 a "
255                   "@attr 4=2 @attr 1=1016 b "));
256
257     YAZ_CHECK(tst_ccl_query(bibset, "spid%æserne",
258                   "@prox 0 1 0 2 k 2 "
259                   "@attr 4=2 @attr 1=1016 spid "
260                   "@attr 4=2 @attr 1=1016 Ã¦serne "));
261
262     YAZ_CHECK(tst_ccl_query(bibset, "a!b",
263                   "@prox 0 1 1 2 k 2 "
264                   "@attr 4=2 @attr 1=1016 a "
265                   "@attr 4=2 @attr 1=1016 b "));
266     YAZ_CHECK(tst_ccl_query(bibset, "a!2b",
267                   "@prox 0 2 1 2 k 2 "
268                   "@attr 4=2 @attr 1=1016 a "
269                   "@attr 4=2 @attr 1=1016 b "));
270
271     YAZ_CHECK(tst_ccl_query(bibset, "a% (b or dc.title=c)",
272                             "@prox 0 1 0 2 k 2 "
273                             "@attr 4=2 @attr 1=1016 a "
274                             "@or @attr 4=2 @attr 1=1016 b "
275                             "@or @attr 4=2 @attr 1=/my/title c "
276                             "@attr 4=2 @attr 1=1016 c "
277     ));
278
279     YAZ_CHECK(tst_ccl_query(bibset, "(a b) % (c)",
280                             "@prox 0 1 0 2 k 2 @and "
281                             "@attr 4=2 @attr 1=1016 a @attr 4=2 @attr 1=1016 b "
282                             "@attr 4=2 @attr 1=1016 c " ));
283
284     YAZ_CHECK(tst_ccl_query(bibset, "date=1980",
285                             "1980 "));
286     YAZ_CHECK(tst_ccl_query(bibset, "(date=1980)",
287                             "1980 "));
288     YAZ_CHECK(tst_ccl_query(bibset, "date>1980",
289                             "@attr 2=5 1980 "));
290     YAZ_CHECK(tst_ccl_query(bibset, "date>=1980",
291                             "@attr 2=4 1980 "));
292     YAZ_CHECK(tst_ccl_query(bibset, "date<1980",
293                             "@attr 2=1 1980 "));
294     YAZ_CHECK(tst_ccl_query(bibset, "date<=1980",
295                             "@attr 2=2 1980 "));
296     YAZ_CHECK(tst_ccl_query(bibset, "date=234-1990",
297                             "@and @attr 2=4 234 @attr 2=2 1990 "));
298     YAZ_CHECK(tst_ccl_query(bibset, "date=234- 1990",
299                             "@and @attr 2=4 234 @attr 2=2 1990 "));
300     YAZ_CHECK(tst_ccl_query(bibset, "date=234 -1990",
301                             "@and @attr 2=4 234 @attr 2=2 1990 "));
302     YAZ_CHECK(tst_ccl_query(bibset, "date=234 - 1990",
303                             "@and @attr 2=4 234 @attr 2=2 1990 "));
304     YAZ_CHECK(tst_ccl_query(bibset, "date=-1980",
305                             "@attr 2=2 1980 "));
306     YAZ_CHECK(tst_ccl_query(bibset, "date=- 1980",
307                             "@attr 2=2 1980 "));
308     YAZ_CHECK(tst_ccl_query(bibset, "x=-1980",
309                             "@attr 2=3 -1980 "));
310     YAZ_CHECK(tst_ccl_query(bibset, "x=- 1980",
311                             "@attr 2=2 1980 "));
312     YAZ_CHECK(tst_ccl_query(bibset, "x= -1980",
313                             "@attr 2=3 -1980 "));
314     YAZ_CHECK(tst_ccl_query(bibset, "x=234-1990",
315                             "@attr 2=3 234-1990 "));
316     YAZ_CHECK(tst_ccl_query(bibset, "x=234 - 1990",
317                             "@and @attr 2=4 234 @attr 2=2 1990 "));
318     YAZ_CHECK(tst_ccl_query(bibset, "ti=a,b",
319                             "@attr 4=1 @attr 1=4 a,b "));
320     YAZ_CHECK(tst_ccl_query(bibset, "ti=a, b",
321                             "@attr 4=1 @attr 1=4 \"a, b\" "));
322     YAZ_CHECK(tst_ccl_query(bibset, "ti=a-b",
323                             "@attr 4=2 @attr 1=4 a-b "));
324     YAZ_CHECK(tst_ccl_query(bibset, "ti=a - b",
325                             "@attr 4=1 @attr 1=4 \"a - b\" "));
326
327     YAZ_CHECK(tst_ccl_query(bibset, "a?",
328                             "@attr 5=1 @attr 4=2 @attr 1=1016 a "));
329     YAZ_CHECK(tst_ccl_query(bibset, "a b",
330                             "@and @attr 4=2 @attr 1=1016 a "
331                             "@attr 4=2 @attr 1=1016 b "));
332
333     YAZ_CHECK(tst_ccl_query(bibset, "a b?",
334                             "@and @attr 4=2 @attr 1=1016 a "
335                             "@attr 5=1 @attr 4=2 @attr 1=1016 b "));
336
337     YAZ_CHECK(tst_ccl_query(bibset, "title=a",
338                             "@attr 1=/my/title a "));
339
340     YAZ_CHECK(tst_ccl_query(bibset, "reg=a?b#\"c?\"",
341                             "@attr 5=102 a.*b.c\\\\? "));
342     YAZ_CHECK(tst_ccl_query(bibset, "z=a?b#\"c?\"",
343                             "@attr 5=104 a?b#c\\\\? "));
344
345     YAZ_CHECK(tst_ccl_query(bibset, "reg=\\(",
346                             "( "));
347     YAZ_CHECK(tst_ccl_query(bibset, "z=\\(",
348                             "( "));
349
350     YAZ_CHECK(tst_ccl_query(bibset, "z=a b#",
351                             "@attr 5=104 \"a b#\" "));
352
353     YAZ_CHECK(tst_ccl_query(bibset, "reg=\\\"",
354                             "\"\\\"\" "));
355     YAZ_CHECK(tst_ccl_query(bibset, "z=\\\"",
356                             "\"\\\"\" "));
357
358     YAZ_CHECK(tst_ccl_query(bibset, "reg=.",
359                             ". "));
360     YAZ_CHECK(tst_ccl_query(bibset, "z=.",
361                             ". "));
362
363     YAZ_CHECK(tst_ccl_query(bibset, "reg=\".\"",
364                             ". "));
365     YAZ_CHECK(tst_ccl_query(bibset, "z=\".\"",
366                             ". "));
367
368     YAZ_CHECK(tst_ccl_query(bibset, "reg=?\\?",
369                             "@attr 5=102 .*\\\\? "));
370     YAZ_CHECK(tst_ccl_query(bibset, "z=?\\?",
371                             "@attr 5=104 ?\\\\? "));
372
373     YAZ_CHECK(tst_ccl_query(bibset, "reg=\"?\\?\"",
374                             "?? "));
375     YAZ_CHECK(tst_ccl_query(bibset, "z=\"?\\?\"",
376                             "?? "));
377
378     YAZ_CHECK(tst_ccl_query(bibset, "reg=\\\\",
379                             "\\\\ "));
380     YAZ_CHECK(tst_ccl_query(bibset, "z=\\\\",
381                             "\\\\ "));
382
383     YAZ_CHECK(tst_ccl_query(bibset, "\\\\",
384                             "@attr 4=2 @attr 1=1016 \\\\ "));
385
386     YAZ_CHECK(tst_ccl_query(bibset, "comb=a",
387                             "@or @attr 4=2 @attr 1=1016 a "
388                             "@attr 1=/my/title a "));
389
390     YAZ_CHECK(tst_ccl_query(bibset, "a? b?",
391                             "@and @attr 5=1 @attr 4=2 @attr 1=1016 a "
392                             "@attr 5=1 @attr 4=2 @attr 1=1016 b "));
393
394     YAZ_CHECK(tst_ccl_query(bibset, "\"a\"? \"b?\"",
395                             "@and @attr 5=1 @attr 4=2 @attr 1=1016 a "
396                             "@attr 4=2 @attr 1=1016 b? "));
397
398     YAZ_CHECK(tst_ccl_query(bibset, "@and",
399                             "@attr 4=2 @attr 1=1016 \\@and "));
400
401     YAZ_CHECK(tst_ccl_query(bibset, "a@and",
402                             "@attr 4=2 @attr 1=1016 a@and "));
403
404     YAZ_CHECK(tst_ccl_query(bibset, "}",
405                             "@attr 4=2 @attr 1=1016 } "));
406
407     YAZ_CHECK(tst_ccl_query(bibset, "{",
408                             "@attr 4=2 @attr 1=1016 \"{\" "));
409
410     YAZ_CHECK(tst_ccl_query(bibset, "\"a b c\"",
411                             "@attr 4=1 @attr 1=1016 \"a b c\" "));
412
413     YAZ_CHECK(tst_ccl_query(bibset, "\"a b  c  \"",
414                             "@attr 4=1 @attr 1=1016 \"a b  c  \" "));
415
416     YAZ_CHECK(tst_ccl_query(bibset, "ag=a",
417                             "@attr 4=2 a "));
418
419     YAZ_CHECK(tst_ccl_query(bibset, "ag=a b",
420                             "@attr 4=2 \"a b\" "));
421
422     YAZ_CHECK(tst_ccl_query(bibset, "ag=a b \"c d\"",
423                             "@and @attr 4=2 \"a b\" @attr 4=1 \"c d\" "));
424
425     YAZ_CHECK(tst_ccl_query(bibset, "ag=a b \"c\"",
426                             "@attr 4=2 \"a b c\" "));
427
428     YAZ_CHECK(tst_ccl_query(bibset, "ag=a b \"\"",
429                             "@attr 4=2 \"a b \" "));
430
431     YAZ_CHECK(tst_ccl_query(bibset, "ag=a \"b c\" d",
432                             "@and @and "
433                             "@attr 4=2 a @attr 4=1 \"b c\" @attr 4=2 d "));
434
435     YAZ_CHECK(tst_ccl_query(bibset, "ag=\"a b c\"",
436                             "@attr 4=1 \"a b c\" "));
437
438     YAZ_CHECK(tst_ccl_query(bibset, "ag=\"a b c\" \"d e\"",
439                             "@and @attr 4=1 \"a b c\" @attr 4=1 \"d e\" "));
440
441     YAZ_CHECK(tst_ccl_query(bibset, "splitlist=a", "@attr 1=2 a "));
442     YAZ_CHECK(tst_ccl_query(bibset, "splitlist=a b", "@or "
443                             "@and @attr 1=2 a @attr 1=2 b @attr 1=2 \"a b\" "));
444     YAZ_CHECK(tst_ccl_query(bibset, "splitlist=a b c", "@or @or @or "
445                             "@and @and @attr 1=2 a @attr 1=2 b @attr 1=2 c "
446                             "@and @attr 1=2 a @attr 1=2 \"b c\" "
447                             "@and @attr 1=2 \"a b\" @attr 1=2 c "
448                             "@attr 1=2 \"a b c\" "));
449     ccl_qual_rm(&bibset);
450 }
451
452 void tst2(void)
453 {
454     CCL_bibset bibset = ccl_qual_mk();
455
456     YAZ_CHECK(bibset);
457     if (!bibset)
458         return;
459
460     ccl_qual_fitem(bibset, "u=4    s=pw t=l,r", "ti");
461     ccl_qual_fitem(bibset, "1=1016 s=al,pw t=z",    "term");
462
463     YAZ_CHECK(tst_ccl_query(bibset, "a?#",
464                             "@attr 5=104 @attr 4=2 @attr 1=1016 a?# "));
465
466     YAZ_CHECK(tst_ccl_query(bibset, "a b?#",
467                             "@and @attr 4=2 @attr 1=1016 a @attr 5=104 @attr 4=2 @attr 1=1016 b?# "));
468
469     YAZ_CHECK(tst_ccl_query(bibset, "a*",
470                             "@attr 4=2 @attr 1=1016 a* "));
471
472     YAZ_CHECK(tst_ccl_query(bibset, "a?",
473                             "@attr 5=104 @attr 4=2 @attr 1=1016 a? "));
474
475     ccl_qual_fitem(bibset, "*", "@truncation");
476     YAZ_CHECK(tst_ccl_query(bibset, "a*",
477                             "@attr 5=104 @attr 4=2 @attr 1=1016 a? "));
478
479     YAZ_CHECK(tst_ccl_query(bibset, "a?",
480                             "@attr 4=2 @attr 1=1016 a? "));
481
482     ccl_qual_fitem(bibset, "?", "@mask");
483     YAZ_CHECK(tst_ccl_query(bibset, "a?",
484                             "@attr 5=104 @attr 4=2 @attr 1=1016 a# "));
485
486
487     ccl_qual_fitem(bibset, "", "@mask");
488     ccl_qual_fitem(bibset, "", "@truncation");
489     YAZ_CHECK(tst_ccl_query(bibset, "a?#",
490                             "@attr 4=2 @attr 1=1016 a?# "));
491
492     ccl_qual_fitem(bibset, "og", "@and");
493     ccl_qual_fitem(bibset, "eller", "@or");
494     ccl_qual_fitem(bibset, "ikke", "@not");
495
496     YAZ_CHECK(tst_ccl_query(bibset, "a og b eller c ikke d",
497                             "@not @or @and @attr 4=2 @attr 1=1016 a "
498                             "@attr 4=2 @attr 1=1016 b "
499                             "@attr 4=2 @attr 1=1016 c "
500                             "@attr 4=2 @attr 1=1016 d "));
501     ccl_qual_rm(&bibset);
502 }
503
504
505 void tst_addinfo(void)
506 {
507     const char *addinfo;
508     int r;
509     CCL_bibset bibset = ccl_qual_mk();
510
511     r = ccl_qual_fitem2(bibset, "u=4    s=pw t=l,r", "ti", &addinfo);
512     YAZ_CHECK(r == 0 && addinfo == 0);
513
514     r = ccl_qual_fitem2(bibset, "1=1016 s=al,pw t=z", "term", &addinfo);
515     YAZ_CHECK(r == 0 && addinfo == 0);
516
517     r = ccl_qual_fitem2(bibset, "x=", "term", &addinfo);
518     YAZ_CHECK(r != 0 && addinfo != 0);
519
520     r = ccl_qual_fitem2(bibset, "12=3", "term", &addinfo);
521     YAZ_CHECK(r == 0 && addinfo == 0);
522
523     r = ccl_qual_fitem2(bibset, "ab=3", "term", &addinfo);
524     YAZ_CHECK(r != 0 && addinfo != 0);
525
526     r = ccl_qual_fitem2(bibset, "x=ab", "term", &addinfo);
527     YAZ_CHECK(r != 0 && addinfo != 0);
528
529     r = ccl_qual_fitem2(bibset, "s=ab", "term", &addinfo);
530     YAZ_CHECK(r == 0 && addinfo == 0);
531
532     ccl_qual_rm(&bibset);
533 }
534
535 int main(int argc, char **argv)
536 {
537     YAZ_CHECK_INIT(argc, argv);
538     YAZ_CHECK_LOG();
539     tst1(0);
540     tst1(1);
541     tst1(2);
542     tst1(3);
543     tst2();
544     tst_addinfo();
545     YAZ_CHECK_TERM;
546 }
547 /*
548  * Local variables:
549  * c-basic-offset: 4
550  * c-file-style: "Stroustrup"
551  * indent-tabs-mode: nil
552  * End:
553  * vim: shiftwidth=4 tabstop=8 expandtab
554  */
555