f5e3e76ba1d928baf755dcd6c9c7892da8287b2d
[yaz-moved-to-github.git] / test / tst_icu_I18N.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2008 Index Data
3  * See the file LICENSE for details.
4  */
5
6 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
7  
8
9 #if HAVE_CONFIG_H
10 #include "config.h"
11 #endif
12
13 #define USE_TIMING 0
14 #if USE_TIMING
15 #include <yaz/timing.h>
16 #endif
17
18 #include <yaz/test.h>
19
20 #if YAZ_HAVE_ICU
21 #include <yaz/icu_I18N.h>
22
23 #include <string.h>
24 #include <stdlib.h>
25
26 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
27
28
29 #define MAX_KEY_SIZE 256
30 struct icu_termmap
31 {
32     uint8_t sort_key[MAX_KEY_SIZE]; /* standard C string '\0' terminated */
33     char disp_term[MAX_KEY_SIZE];  /* standard C utf-8 string */
34 };
35
36
37
38 int icu_termmap_cmp(const void *vp1, const void *vp2)
39 {
40     struct icu_termmap *itmp1 = *(struct icu_termmap **) vp1;
41     struct icu_termmap *itmp2 = *(struct icu_termmap **) vp2;
42
43     int cmp = 0;
44     
45     cmp = strcmp((const char *)itmp1->sort_key, 
46                  (const char *)itmp2->sort_key);
47     return cmp;
48 };
49
50
51
52
53 int test_icu_casemap(const char * locale, char action,
54                      const char * src8cstr, const char * chk8cstr)
55 {
56     int success = 0;
57     UErrorCode status = U_ZERO_ERROR;
58
59     struct icu_buf_utf8 * src8 = icu_buf_utf8_create(0);
60     struct icu_buf_utf8 * dest8 = icu_buf_utf8_create(0);
61     struct icu_buf_utf16 * src16 = icu_buf_utf16_create(0);
62     struct icu_buf_utf16 * dest16 = icu_buf_utf16_create(0);
63
64
65     int src8cstr_len = strlen(src8cstr);
66     int chk8cstr_len = strlen(chk8cstr);
67
68     /* converting to UTF16 */
69     icu_utf16_from_utf8_cstr(src16, src8cstr, &status);
70
71     /* perform case mapping */
72     icu_utf16_casemap(dest16, src16, locale, action, &status);
73   
74     /* converting to UTF8 */
75     icu_utf16_to_utf8(dest8, dest16, &status);
76       
77
78   
79     /* determine success */
80     if (dest8->utf8 
81         && (dest8->utf8_len == strlen(chk8cstr))
82         && !strcmp(chk8cstr, (const char *) dest8->utf8))
83         success = 1;
84     else
85         success = 0;
86
87     /* report failures */
88     if (!success){
89         printf("\nERROR\n");
90         printf("original string:   '%s' (%d)\n", src8cstr, src8cstr_len);
91         printf("icu_casemap '%s:%c' '%s' (%d)\n", 
92                locale, action, dest8->utf8, dest8->utf8_len);
93         printf("expected string:   '%s' (%d)\n", chk8cstr, chk8cstr_len);
94     }
95   
96     /* clean the buffers */
97     icu_buf_utf8_destroy(src8);
98     icu_buf_utf8_destroy(dest8);
99     icu_buf_utf16_destroy(src16);
100     icu_buf_utf16_destroy(dest16);
101   
102   
103     return success;
104 }
105
106
107
108 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
109
110 void test_icu_I18N_casemap(int argc, char **argv)
111 {
112
113     /* Locale 'en' */
114
115     /* successful tests */
116     YAZ_CHECK(test_icu_casemap("en", 'l',
117                                "A ReD fOx hunTS sQUirriLs", 
118                                "a red fox hunts squirrils"));
119     
120     YAZ_CHECK(test_icu_casemap("en", 'u',
121                                "A ReD fOx hunTS sQUirriLs", 
122                                "A RED FOX HUNTS SQUIRRILS"));
123     
124     YAZ_CHECK(test_icu_casemap("en", 'f',
125                                "A ReD fOx hunTS sQUirriLs", 
126                                "a red fox hunts squirrils"));
127     
128     YAZ_CHECK(test_icu_casemap("en", 't',
129                                "A ReD fOx hunTS sQUirriLs", 
130                                "A Red Fox Hunts Squirrils"));
131     
132
133     /* Locale 'da' */
134
135     /* success expected */
136     YAZ_CHECK(test_icu_casemap("da", 'l',
137                                "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN", 
138                                "åh æble, øs fløde i åen efter blåbærgrøden"));
139
140     YAZ_CHECK(test_icu_casemap("da", 'u',
141                                "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN", 
142                                "ÅH ÆBLE, ØS FLØDE I ÅEN EFTER BLÅBÆRGRØDEN"));
143
144     YAZ_CHECK(test_icu_casemap("da", 'f',
145                                "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN", 
146                                "åh æble, øs fløde i åen efter blåbærgrøden"));
147
148     YAZ_CHECK(test_icu_casemap("da", 't',
149                                "åh ÆbLE, øs fLØde i Åen efter bLåBærGRødeN", 
150                                "Åh Æble, Øs Fløde I Åen Efter Blåbærgrøden"));
151
152     /* Locale 'de' */
153
154     /* success expected */
155     YAZ_CHECK(test_icu_casemap("de", 'l',
156                                "zWÖlf ärgerliche Würste rollen ÜBer die StRAße",
157                                "zwölf ärgerliche würste rollen über die straße"));
158
159     YAZ_CHECK(test_icu_casemap("de", 'u',
160                                "zWÖlf ärgerliche Würste rollen ÜBer die StRAße",
161                                "ZWÖLF ÄRGERLICHE WÜRSTE ROLLEN ÜBER DIE STRASSE"));
162
163     YAZ_CHECK(test_icu_casemap("de", 'f',
164                                "zWÖlf ärgerliche Würste rollen ÜBer die StRAße",
165                                "zwölf ärgerliche würste rollen über die strasse"));
166
167     YAZ_CHECK(test_icu_casemap("de", 't',
168                                "zWÖlf ärgerliche Würste rollen ÜBer die StRAße",
169                                "Zwölf Ärgerliche Würste Rollen Über Die Straße"));
170
171 }
172
173
174 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
175
176 int test_icu_sortmap(const char * locale, int src_list_len,
177                      const char ** src_list, const char ** chk_list)
178 {
179     int success = 1;
180
181     UErrorCode status = U_ZERO_ERROR;
182
183     struct icu_buf_utf8 * buf8 = icu_buf_utf8_create(0);
184     struct icu_buf_utf16 * buf16 = icu_buf_utf16_create(0);
185
186     int i;
187
188     struct icu_termmap * list[src_list_len];
189
190     UCollator *coll = ucol_open(locale, &status); 
191     icu_check_status(status);
192
193     if(U_FAILURE(status))
194         return 0;
195
196     /* assigning display terms and sort keys using buf 8 and buf16 */
197     for( i = 0; i < src_list_len; i++) 
198         {
199
200             list[i] = (struct icu_termmap *) malloc(sizeof(struct icu_termmap));
201
202             /* copy display term */
203             strcpy(list[i]->disp_term, src_list[i]);    
204
205             /* transforming to UTF16 */
206             icu_utf16_from_utf8_cstr(buf16, list[i]->disp_term, &status);
207             icu_check_status(status);
208
209             /* computing sortkeys */
210             icu_sortkey8_from_utf16(coll, buf8, buf16, &status);
211             icu_check_status(status);
212     
213             /* assigning sortkeys */
214             memcpy(list[i]->sort_key, buf8->utf8, buf8->utf8_len);    
215         } 
216
217
218     /* do the sorting */
219     qsort(list, src_list_len, 
220           sizeof(struct icu_termmap *), icu_termmap_cmp);
221
222     /* checking correct sorting */
223     for (i = 0; i < src_list_len; i++){
224         if (0 != strcmp(list[i]->disp_term, chk_list[i])){
225             success = 0;
226         }
227     }
228
229     if(!success){
230         printf("\nERROR\n"); 
231         printf("Input str: '%s' : ", locale); 
232         for (i = 0; i < src_list_len; i++) {
233             printf(" '%s'", list[i]->disp_term); 
234         }
235         printf("\n");
236         printf("ICU sort:  '%s' : ", locale); 
237         for (i = 0; i < src_list_len; i++) {
238             printf(" '%s'", list[i]->disp_term); 
239         }
240         printf("\n"); 
241         printf("Expected:  '%s' : ", locale); 
242         for (i = 0; i < src_list_len; i++) {
243             printf(" '%s'", chk_list[i]); 
244         }
245         printf("\n"); 
246     }
247   
248
249
250     for( i = 0; i < src_list_len; i++)
251         free(list[i]);
252         
253     
254     ucol_close(coll);
255
256     icu_buf_utf8_destroy(buf8);
257     icu_buf_utf16_destroy(buf16);
258
259     return success;  
260 }
261
262
263 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
264
265 void test_icu_I18N_sortmap(int argc, char **argv)
266 {
267
268     /* successful tests */
269     size_t en_1_len = 6;
270     const char * en_1_src[6] = {"z", "K", "a", "A", "Z", "k"};
271     const char * en_1_cck[6] = {"a", "A", "k", "K", "z", "Z"};
272     YAZ_CHECK(test_icu_sortmap("en", en_1_len, en_1_src, en_1_cck));
273     YAZ_CHECK(test_icu_sortmap("en_AU", en_1_len, en_1_src, en_1_cck));
274     YAZ_CHECK(test_icu_sortmap("en_CA", en_1_len, en_1_src, en_1_cck));
275     YAZ_CHECK(test_icu_sortmap("en_GB", en_1_len, en_1_src, en_1_cck));
276     YAZ_CHECK(test_icu_sortmap("en_US", en_1_len, en_1_src, en_1_cck));
277     
278     /* successful tests */
279     {
280         size_t da_1_len = 6;
281         const char * da_1_src[6] = {"z", "å", "o", "æ", "a", "ø"};
282         const char * da_1_cck[6] = {"a", "o", "z", "æ", "ø", "å"};
283         YAZ_CHECK(test_icu_sortmap("da", da_1_len, da_1_src, da_1_cck));
284         YAZ_CHECK(test_icu_sortmap("da_DK", da_1_len, da_1_src, da_1_cck));
285     }
286     /* successful tests */
287     {
288         size_t de_1_len = 9;
289         const char * de_1_src[9] = {"u", "ä", "o", "t", "s", "ß", "ü", "ö", "a"};
290         const char * de_1_cck[9] = {"a","ä", "o", "ö", "s", "ß", "t", "u", "ü"};
291         YAZ_CHECK(test_icu_sortmap("de", de_1_len, de_1_src, de_1_cck));
292         YAZ_CHECK(test_icu_sortmap("de_AT", de_1_len, de_1_src, de_1_cck));
293         YAZ_CHECK(test_icu_sortmap("de_DE", de_1_len, de_1_src, de_1_cck));
294     }
295     
296 }
297
298
299 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
300
301
302
303
304 int test_icu_normalizer(const char * rules8cstr,
305                             const char * src8cstr,
306                             const char * chk8cstr)
307 {
308     int success = 0;
309     
310     UErrorCode status = U_ZERO_ERROR;
311
312     struct icu_buf_utf16 * src16 = icu_buf_utf16_create(0);
313     struct icu_buf_utf16 * dest16 = icu_buf_utf16_create(0);
314     struct icu_buf_utf8 * dest8 = icu_buf_utf8_create(0);
315     struct icu_normalizer * normalizer
316         = icu_normalizer_create(rules8cstr, 'f', &status);
317     icu_check_status(status);
318     
319     icu_utf16_from_utf8_cstr(src16, src8cstr, &status);
320     icu_check_status(status);
321
322     icu_normalizer_normalize(normalizer, dest16, src16, &status);
323     icu_check_status(status);
324
325     icu_utf16_to_utf8(dest8, dest16, &status);
326     icu_check_status(status);
327
328
329     if(!strcmp((const char *) dest8->utf8, 
330                (const char *) chk8cstr))
331         success = 1;
332     else {
333         success = 0;
334         printf("Normalization\n");
335         printf("Rules:      '%s'\n", rules8cstr);
336         printf("Input:      '%s'\n", src8cstr);
337         printf("Normalized: '%s'\n", dest8->utf8);
338         printf("Expected:   '%s'\n", chk8cstr);
339     }
340     
341
342     icu_normalizer_destroy(normalizer);
343     icu_buf_utf16_destroy(src16);
344     icu_buf_utf16_destroy(dest16);
345     icu_buf_utf8_destroy(dest8);
346
347     return success;
348 };
349
350
351 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
352
353 void test_icu_I18N_normalizer(int argc, char **argv)
354 {
355
356     YAZ_CHECK(test_icu_normalizer("[:Punctuation:] Any-Remove",
357                                   "Don't shoot!",
358                                   "Dont shoot"));
359     
360     YAZ_CHECK(test_icu_normalizer("[:Control:] Any-Remove",
361                                   "Don't\n shoot!",
362                                   "Don't shoot!"));
363
364     YAZ_CHECK(test_icu_normalizer("[:Decimal_Number:] Any-Remove",
365                                   "This is 4 you!",
366                                   "This is  you!"));
367
368     YAZ_CHECK(test_icu_normalizer("Lower; [:^Letter:] Remove",
369                                   "Don't shoot!",
370                                   "dontshoot"));
371     
372     YAZ_CHECK(test_icu_normalizer("[:^Number:] Remove",
373                                   "Monday 15th of April",
374                                   "15"));
375
376     YAZ_CHECK(test_icu_normalizer("Lower;"
377                                   "[[:WhiteSpace:][:Punctuation:]] Remove",
378                                   " word4you? ",
379                                   "word4you"));
380
381
382     YAZ_CHECK(test_icu_normalizer("NFD; [:Nonspacing Mark:] Remove; NFC",
383                                   "à côté de l'alcôve ovoïde",
384                                   "a cote de l'alcove ovoide"));
385
386 }
387
388
389 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
390
391 int test_icu_tokenizer(const char * locale, char action,
392                      const char * src8cstr, int count)
393 {
394     int success = 1;
395
396     UErrorCode status = U_ZERO_ERROR;
397     struct icu_buf_utf16 * src16 = icu_buf_utf16_create(0);
398     struct icu_buf_utf16 * tkn16 = icu_buf_utf16_create(0);
399     struct icu_buf_utf8 * tkn8 = icu_buf_utf8_create(0);
400     struct icu_tokenizer * tokenizer = 0;
401
402     /* transforming to UTF16 */
403     icu_utf16_from_utf8_cstr(src16, src8cstr, &status);
404     icu_check_status(status);
405
406     /* set up tokenizer */
407     tokenizer = icu_tokenizer_create(locale, action, &status);
408     icu_check_status(status);
409     YAZ_CHECK(tokenizer);
410
411     /* attach text buffer to tokenizer */
412     icu_tokenizer_attach(tokenizer, src16, &status);    
413     icu_check_status(status);
414     YAZ_CHECK(tokenizer->bi);
415
416     /* perform work on tokens */
417     while(icu_tokenizer_next_token(tokenizer, tkn16, &status)){
418         icu_check_status(status);
419
420         /* converting to UTF8 */
421         icu_utf16_to_utf8(tkn8, tkn16, &status);
422     }
423
424     if (count != icu_tokenizer_token_count(tokenizer)){
425         success = 0;
426         printf("\nTokenizer '%s:%c' Error: \n", locale, action);
427         printf("Input:  '%s'\n", src8cstr);
428         printf("Tokens: %d", icu_tokenizer_token_count(tokenizer));
429         printf(", expected: %d\n", count);
430     }
431
432     icu_tokenizer_destroy(tokenizer);
433     icu_buf_utf16_destroy(src16);
434     icu_buf_utf16_destroy(tkn16);
435     icu_buf_utf8_destroy(tkn8);
436         
437     return success;
438 }
439
440
441 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
442
443 void test_icu_I18N_tokenizer(int argc, char **argv)
444 {
445
446
447     const char * en_str 
448         = "O Romeo, Romeo! wherefore art thou Romeo?";
449     
450     YAZ_CHECK(test_icu_tokenizer("en", 's', en_str, 2));
451     YAZ_CHECK(test_icu_tokenizer("en", 'l', en_str, 7));
452     YAZ_CHECK(test_icu_tokenizer("en", 'w', en_str, 16));
453     YAZ_CHECK(test_icu_tokenizer("en", 'c', en_str, 41));
454
455
456
457     {
458         const char * da_str 
459             = "Blåbærtærte. Denne kage stammer fra Finland. "
460             "Den er med blåbær, men alle sommerens forskellige bær kan bruges.";
461         
462         YAZ_CHECK(test_icu_tokenizer("da", 's', da_str, 3));
463         YAZ_CHECK(test_icu_tokenizer("dar", 'l', da_str, 17));
464         YAZ_CHECK(test_icu_tokenizer("da", 'w', da_str, 37));
465         YAZ_CHECK(test_icu_tokenizer("da", 'c', da_str, 110));
466     }
467
468 }
469
470
471 void test_icu_I18N_chain(int argc, char **argv)
472 {
473     const char * en_str 
474         = "O Romeo, Romeo! wherefore art thou\t Romeo?";
475
476     UErrorCode status = U_ZERO_ERROR;
477     struct icu_chain * chain = 0;
478     
479
480     const char * xml_str = "<icu locale=\"en\">"
481         "<transform rule=\"[:Control:] Any-Remove\"/>"
482         "<tokenize rule=\"l\"/>"
483         "<transform rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
484         "<display/>"
485         "<casemap rule=\"l\"/>"
486         "</icu>";
487
488     
489     xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
490     xmlNode *xml_node = xmlDocGetRootElement(doc);
491     YAZ_CHECK(xml_node);
492
493     chain = icu_chain_xml_config(xml_node, 0, &status);
494
495     xmlFreeDoc(doc);
496     YAZ_CHECK(chain);
497
498     YAZ_CHECK(icu_chain_assign_cstr(chain, en_str, &status));
499
500     while (icu_chain_next_token(chain, &status)){
501         ;
502         /* printf("%d '%s' '%s'\n",
503                icu_chain_token_number(chain),
504                icu_chain_token_norm(chain),
505                icu_chain_token_display(chain)); */
506     }
507
508     YAZ_CHECK_EQ(icu_chain_token_number(chain), 7);
509
510
511     YAZ_CHECK(icu_chain_assign_cstr(chain, "what is this?", &status));
512
513     while (icu_chain_next_token(chain, &status)){
514         ;
515         /* printf("%d '%s' '%s'\n",
516                icu_chain_token_number(chain),
517                icu_chain_token_norm(chain),
518                icu_chain_token_display(chain)); */
519     }
520
521
522     YAZ_CHECK_EQ(icu_chain_token_number(chain), 3);
523
524     icu_chain_destroy(chain);
525 }
526
527
528 void test_bug_1140(void)
529 {
530     UErrorCode status = U_ZERO_ERROR;
531     struct icu_chain * chain = 0;
532     
533     const char * xml_str = "<icu locale=\"en\">"
534
535         /* if the first rule is normalize instead. Then it works */
536 #if 0
537         "<transform rule=\"[:Control:] Any-Remove\"/>"
538 #endif
539         "<tokenize rule=\"l\"/>"
540         "<transform rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
541         "<display/>"
542         "<casemap rule=\"l\"/>"
543         "</icu>";
544
545     
546     xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
547     xmlNode *xml_node = xmlDocGetRootElement(doc);
548     YAZ_CHECK(xml_node);
549
550     chain = icu_chain_xml_config(xml_node, 0, &status);
551
552     xmlFreeDoc(doc);
553     YAZ_CHECK(chain);
554     
555     YAZ_CHECK(icu_chain_assign_cstr(
556                   chain,  "O Romeo, Romeo! wherefore art thou\t Romeo?",
557                   &status));
558
559     while (icu_chain_next_token(chain, &status)){    
560         ;
561         /* printf("%d '%s' '%s'\n",
562                icu_chain_token_number(chain),
563                icu_chain_token_norm(chain),
564                icu_chain_token_display(chain)); */
565
566     }
567     
568
569     YAZ_CHECK_EQ(icu_chain_token_number(chain), 7);
570
571     YAZ_CHECK(icu_chain_assign_cstr(chain, "what is this?", &status));
572
573     while (icu_chain_next_token(chain, &status)){
574        ;
575        /* printf("%d '%s' '%s'\n",
576                icu_chain_token_number(chain),
577                icu_chain_token_norm(chain),
578                icu_chain_token_display(chain)); */
579     }
580
581     /* we expect 'what' 'is' 'this', i.e. 3 tokens */
582     YAZ_CHECK_EQ(icu_chain_token_number(chain), 3);
583
584     icu_chain_destroy(chain);
585 }
586
587
588
589 void test_chain_empty_token(void)
590 {
591     UErrorCode status = U_ZERO_ERROR;
592     struct icu_chain * chain = 0;
593
594     const char * xml_str = "<icu locale=\"en\">"
595         "<tokenize rule=\"w\"/>"
596         "<transform rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
597         "</icu>";
598     
599     xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
600     xmlNode *xml_node = xmlDocGetRootElement(doc);
601     YAZ_CHECK(xml_node);
602
603     chain = icu_chain_xml_config(xml_node, 0, &status);
604
605     xmlFreeDoc(doc);
606     YAZ_CHECK(chain);
607     
608     YAZ_CHECK(icu_chain_assign_cstr(
609                   chain,  "a string with 15 tokenss and 8 displays",
610                   &status));
611
612     while (icu_chain_next_token(chain, &status)){
613         ;
614         /* printf("%d '%s' '%s'\n",
615                icu_chain_token_number(chain),
616                icu_chain_token_norm(chain),
617                icu_chain_token_display(chain)); */
618     }
619
620     YAZ_CHECK_EQ(icu_chain_token_number(chain), 15);
621
622     icu_chain_destroy(chain);
623 }
624
625 void test_chain_empty_chain(void)
626 {
627     UErrorCode status = U_ZERO_ERROR;
628     struct icu_chain * chain = 0;
629
630     const char * xml_str = "<icu locale=\"en\">"
631         "</icu>";
632     
633     const char * src8 = "some 5487 weired !¤%&(/& sTuFf";
634     char * dest8 = 0;
635
636     xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
637     xmlNode *xml_node = xmlDocGetRootElement(doc);
638     YAZ_CHECK(xml_node);
639
640     chain = icu_chain_xml_config(xml_node, 0, &status);
641
642     xmlFreeDoc(doc);
643     YAZ_CHECK(chain);
644     
645     YAZ_CHECK(icu_chain_assign_cstr(
646                   chain,  src8,
647                   &status));
648
649     while (icu_chain_next_token(chain, &status)){
650         ;
651         /* printf("%d '%s' '%s'\n",
652                icu_chain_token_number(chain),
653                icu_chain_token_norm(chain),
654                icu_chain_token_display(chain)); */
655     }
656
657     YAZ_CHECK_EQ(icu_chain_token_number(chain), 1);
658
659     dest8 = (char *) icu_chain_token_norm(chain);
660     YAZ_CHECK_EQ(strcmp(src8, dest8), 0);
661     
662
663     icu_chain_destroy(chain);
664 }
665
666 #endif /* YAZ_HAVE_ICU */
667
668 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
669
670 int main(int argc, char **argv)
671 {
672
673     YAZ_CHECK_INIT(argc, argv); 
674     YAZ_CHECK_LOG();
675
676 #if YAZ_HAVE_ICU
677
678     test_icu_I18N_casemap(argc, argv);
679     test_icu_I18N_sortmap(argc, argv);
680     test_icu_I18N_normalizer(argc, argv); 
681     test_icu_I18N_tokenizer(argc, argv);
682     test_icu_I18N_chain(argc, argv);
683     test_chain_empty_token();
684     test_chain_empty_chain();
685     test_bug_1140();
686
687 #else /* YAZ_HAVE_ICU */
688
689     printf("ICU unit tests omitted.\n"
690            "Please install libicu36-dev and icu-doc or similar\n");
691     YAZ_CHECK(0 == 0);
692
693 #endif /* YAZ_HAVE_ICU */
694    
695     YAZ_CHECK_TERM;
696 }
697
698
699 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
700
701
702
703 /*
704  * Local variables:
705  * c-basic-offset: 4
706  * indent-tabs-mode: nil
707  * End:
708  * vim: shiftwidth=4 tabstop=8 expandtab
709  */