17c5a697dea82cc541135c1ea17aca5d9549fb14
[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.13 2007-11-08 09:03:11 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>"
484         "<normalize rule=\"[:Control:] Any-Remove\"/>"
485         "<tokenize rule=\"l\"/>"
486         "<normalize 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
497     chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
498
499     xmlFreeDoc(doc);
500     YAZ_CHECK(chain);
501
502     YAZ_CHECK(icu_chain_assign_cstr(chain, en_str, &status));
503
504     while (icu_chain_next_token(chain, &status)){
505         ;
506         /* printf("%d '%s' '%s'\n",
507                icu_chain_token_number(chain),
508                icu_chain_token_norm(chain),
509                icu_chain_token_display(chain)); */
510     }
511
512     YAZ_CHECK_EQ(icu_chain_token_number(chain), 7);
513
514
515     YAZ_CHECK(icu_chain_assign_cstr(chain, "what is this?", &status));
516
517     while (icu_chain_next_token(chain, &status)){
518         ;
519         /* printf("%d '%s' '%s'\n",
520                icu_chain_token_number(chain),
521                icu_chain_token_norm(chain),
522                icu_chain_token_display(chain)); */
523     }
524
525
526     YAZ_CHECK_EQ(icu_chain_token_number(chain), 3);
527
528     icu_chain_destroy(chain);
529 }
530
531
532 void test_bug_1140(void)
533 {
534     UErrorCode status = U_ZERO_ERROR;
535     struct icu_chain * chain = 0;
536     
537     const char * xml_str = "<icu>"
538
539         /* if the first rule is normalize instead. Then it works */
540 #if 0
541         "<normalize rule=\"[:Control:] Any-Remove\"/>"
542 #endif
543         "<tokenize rule=\"l\"/>"
544         "<normalize rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
545         "<display/>"
546         "<casemap rule=\"l\"/>"
547         "</icu>";
548
549     
550     xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
551     xmlNode *xml_node = xmlDocGetRootElement(doc);
552     YAZ_CHECK(xml_node);
553
554     chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
555
556     xmlFreeDoc(doc);
557     YAZ_CHECK(chain);
558     
559     YAZ_CHECK(icu_chain_assign_cstr(
560                   chain,  "O Romeo, Romeo! wherefore art thou\t Romeo?",
561                   &status));
562
563     while (icu_chain_next_token(chain, &status)){    
564         ;
565         /* printf("%d '%s' '%s'\n",
566                icu_chain_token_number(chain),
567                icu_chain_token_norm(chain),
568                icu_chain_token_display(chain)); */
569
570     }
571     
572
573     YAZ_CHECK_EQ(icu_chain_token_number(chain), 7);
574
575     YAZ_CHECK(icu_chain_assign_cstr(chain, "what is this?", &status));
576
577     while (icu_chain_next_token(chain, &status)){
578        ;
579        /* printf("%d '%s' '%s'\n",
580                icu_chain_token_number(chain),
581                icu_chain_token_norm(chain),
582                icu_chain_token_display(chain)); */
583     }
584
585     /* we expect 'what' 'is' 'this', i.e. 3 tokens */
586     YAZ_CHECK_EQ(icu_chain_token_number(chain), 3);
587
588     icu_chain_destroy(chain);
589 }
590
591
592
593 void test_chain_empty_token(void)
594 {
595     UErrorCode status = U_ZERO_ERROR;
596     struct icu_chain * chain = 0;
597
598     const char * xml_str = "<icu>"
599         "<tokenize rule=\"w\"/>"
600         "<normalize rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
601         "</icu>";
602     
603     xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
604     xmlNode *xml_node = xmlDocGetRootElement(doc);
605     YAZ_CHECK(xml_node);
606
607     chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
608
609     xmlFreeDoc(doc);
610     YAZ_CHECK(chain);
611     
612     YAZ_CHECK(icu_chain_assign_cstr(
613                   chain,  "a string with 15 tokenss and 8 displays",
614                   &status));
615
616     while (icu_chain_next_token(chain, &status)){
617         ;
618         /* printf("%d '%s' '%s'\n",
619                icu_chain_token_number(chain),
620                icu_chain_token_norm(chain),
621                icu_chain_token_display(chain)); */
622     }
623
624     YAZ_CHECK_EQ(icu_chain_token_number(chain), 15);
625
626     icu_chain_destroy(chain);
627 }
628
629 void test_chain_empty_chain(void)
630 {
631     UErrorCode status = U_ZERO_ERROR;
632     struct icu_chain * chain = 0;
633
634     const char * xml_str = "<icu>"
635         "</icu>";
636     
637     const char * src8 = "some 5487 weired !¤%&(/& sTuFf";
638     char * dest8 = 0;
639
640     xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
641     xmlNode *xml_node = xmlDocGetRootElement(doc);
642     YAZ_CHECK(xml_node);
643
644     chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", 0, &status);
645
646     xmlFreeDoc(doc);
647     YAZ_CHECK(chain);
648     
649     YAZ_CHECK(icu_chain_assign_cstr(
650                   chain,  src8,
651                   &status));
652
653     while (icu_chain_next_token(chain, &status)){
654         ;
655         /* printf("%d '%s' '%s'\n",
656                icu_chain_token_number(chain),
657                icu_chain_token_norm(chain),
658                icu_chain_token_display(chain)); */
659     }
660
661     YAZ_CHECK_EQ(icu_chain_token_number(chain), 1);
662
663     dest8 = (char *) icu_chain_token_norm(chain);
664     YAZ_CHECK_EQ(strcmp(src8, dest8), 0);
665     
666
667     icu_chain_destroy(chain);
668 }
669
670 #endif /* YAZ_HAVE_ICU */
671
672 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
673
674 int main(int argc, char **argv)
675 {
676
677     YAZ_CHECK_INIT(argc, argv); 
678     YAZ_CHECK_LOG();
679
680 #if YAZ_HAVE_ICU
681
682     test_icu_I18N_casemap(argc, argv);
683     test_icu_I18N_sortmap(argc, argv);
684     test_icu_I18N_normalizer(argc, argv); 
685     test_icu_I18N_tokenizer(argc, argv);
686     test_icu_I18N_chain(argc, argv);
687     test_chain_empty_token();
688     test_chain_empty_chain();
689     test_bug_1140();
690
691 #else /* YAZ_HAVE_ICU */
692
693     printf("ICU unit tests omitted.\n"
694            "Please install libicu36-dev and icu-doc or similar\n");
695     YAZ_CHECK(0 == 0);
696
697 #endif /* YAZ_HAVE_ICU */
698    
699     YAZ_CHECK_TERM;
700 }
701
702
703 /* DO NOT EDIT THIS FILE IF YOUR EDITOR DOES NOT SUPPORT UTF-8 */
704
705
706
707 /*
708  * Local variables:
709  * c-basic-offset: 4
710  * indent-tabs-mode: nil
711  * End:
712  * vim: shiftwidth=4 tabstop=8 expandtab
713  */