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