]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/cintltst/trietest.c
2 ******************************************************************************
4 * Copyright (C) 2001-2008, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
8 * file name: trietest.c
10 * tab size: 8 (not used)
13 * created on: 2001nov20
14 * created by: Markus W. Scherer
18 #include "unicode/utypes.h"
26 /* definitions from standalone utrie development */
27 #define log_err printf
28 #define log_verbose printf
31 #define u_errorName(errorCode) "some error code"
34 #define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0]))
36 /* Values for setting possibly overlapping, out-of-order ranges of values */
37 typedef struct SetRange
{
45 * value is set from the previous boundary's limit to before
46 * this boundary's limit
48 typedef struct CheckRange
{
54 static uint32_t U_CALLCONV
55 _testFoldedValue32(UNewTrie
*trie
, UChar32 start
, int32_t offset
) {
56 uint32_t foldedValue
, value
;
64 value
=utrie_get32(trie
, start
, &inBlockZero
);
66 start
+=UTRIE_DATA_BLOCK_LENGTH
;
74 return ((uint32_t)offset
<<16)|foldedValue
;
80 static int32_t U_CALLCONV
81 _testFoldingOffset32(uint32_t data
) {
82 return (int32_t)(data
>>16);
85 static uint32_t U_CALLCONV
86 _testFoldedValue16(UNewTrie
*trie
, UChar32 start
, int32_t offset
) {
87 uint32_t foldedValue
, value
;
95 value
=utrie_get32(trie
, start
, &inBlockZero
);
97 start
+=UTRIE_DATA_BLOCK_LENGTH
;
105 return (uint32_t)(offset
|0x8000);
111 static int32_t U_CALLCONV
112 _testFoldingOffset16(uint32_t data
) {
114 return (int32_t)(data
&0x7fff);
120 static uint32_t U_CALLCONV
121 _testEnumValue(const void *context
, uint32_t value
) {
125 static UBool U_CALLCONV
126 _testEnumRange(const void *context
, UChar32 start
, UChar32 limit
, uint32_t value
) {
127 const CheckRange
**pb
=(const CheckRange
**)context
;
128 const CheckRange
*b
=(*pb
)++;
131 if(start
!=(b
-1)->limit
|| limit
!=b
->limit
|| value
!=b
->value
) {
132 log_err("error: utrie_enum() delivers wrong range [U+%04lx..U+%04lx[.0x%lx instead of [U+%04lx..U+%04lx[.0x%lx\n",
134 (b
-1)->limit
, b
->limit
, b
->value
);
140 testTrieIteration(const char *testName
,
142 const CheckRange checkRanges
[], int32_t countCheckRanges
) {
146 const UChar
*p
, *limit
;
150 int32_t i
, length
, countValues
;
154 length
=countValues
=0;
155 for(i
=0; i
<countCheckRanges
; ++i
) {
156 c
=checkRanges
[i
].limit
;
159 UTF_APPEND_CHAR_UNSAFE(s
, length
, c
);
160 values
[countValues
++]=checkRanges
[i
].value
;
170 if(trie
->data32
!=NULL
) {
171 UTRIE_NEXT32(trie
, p
, limit
, c
, c2
, value
);
173 UTRIE_NEXT16(trie
, p
, limit
, c
, c2
, value
);
175 if(value
!=values
[i
]) {
176 log_err("error: wrong value from UTRIE_NEXT(%s)(U+%04lx, U+%04lx): 0x%lx instead of 0x%lx\n",
177 testName
, c
, c2
, value
, values
[i
]);
182 !UTF_IS_LEAD(c
) || !UTF_IS_TRAIL(c2
) || c
!=*(p
-2) || c2
!=*(p
-1)
184 log_err("error: wrong (c, c2) from UTRIE_NEXT(%s): (U+%04lx, U+%04lx)\n",
191 if(trie
->data32
==NULL
) {
192 value
=UTRIE_GET16_FROM_LEAD(trie
, c
);
193 offset
=trie
->getFoldingOffset(value
);
195 value
=UTRIE_GET16_FROM_OFFSET_TRAIL(trie
, offset
, c2
);
197 value
=trie
->initialValue
;
200 value
=UTRIE_GET32_FROM_LEAD(trie
, c
);
201 offset
=trie
->getFoldingOffset(value
);
203 value
=UTRIE_GET32_FROM_OFFSET_TRAIL(trie
, offset
, c2
);
205 value
=trie
->initialValue
;
208 if(value
!=values
[i
]) {
209 log_err("error: wrong value from UTRIE_GETXX_FROM_OFFSET_TRAIL(%s)(U+%04lx, U+%04lx): 0x%lx instead of 0x%lx\n",
210 testName
, c
, c2
, value
, values
[i
]);
215 if(trie
->data32
==NULL
) {
216 UTRIE_GET16_FROM_PAIR(trie
, c
, c2
, value
);
218 UTRIE_GET32_FROM_PAIR(trie
, c
, c2
, value
);
220 if(value
!=values
[i
]) {
221 log_err("error: wrong value from UTRIE_GETXX_FROM_PAIR(%s)(U+%04lx, U+%04lx): 0x%lx instead of 0x%lx\n",
222 testName
, c
, c2
, value
, values
[i
]);
234 if(trie
->data32
!=NULL
) {
235 UTRIE_PREVIOUS32(trie
, s
, p
, c
, c2
, value
);
237 UTRIE_PREVIOUS16(trie
, s
, p
, c
, c2
, value
);
239 if(value
!=values
[i
]) {
240 log_err("error: wrong value from UTRIE_PREVIOUS(%s)(U+%04lx, U+%04lx): 0x%lx instead of 0x%lx\n",
241 testName
, c
, c2
, value
, values
[i
]);
246 !UTF_IS_LEAD(c
) || !UTF_IS_TRAIL(c2
) || c
!=*p
|| c2
!=*(p
+1)
248 log_err("error: wrong (c, c2) from UTRIE_PREVIOUS(%s): (U+%04lx, U+%04lx)\n",
255 testTrieRangesWithMalloc(const char *testName
,
256 const SetRange setRanges
[], int32_t countSetRanges
,
257 const CheckRange checkRanges
[], int32_t countCheckRanges
,
258 UBool dataIs32
, UBool latin1Linear
) {
259 UTrieGetFoldingOffset
*getFoldingOffset
;
260 const CheckRange
*enumRanges
;
263 uint32_t value
, value2
;
264 UChar32 start
, limit
;
266 UErrorCode errorCode
;
268 uint8_t* storage
=NULL
;
269 static const int32_t DEFAULT_STORAGE_SIZE
= 32768;
270 storage
= (uint8_t*) uprv_malloc(sizeof(uint8_t)*DEFAULT_STORAGE_SIZE
);
272 log_verbose("\ntesting Trie '%s'\n", testName
);
273 newTrie
=utrie_open(NULL
, NULL
, 2000,
274 checkRanges
[0].value
, checkRanges
[0].value
,
277 /* set values from setRanges[] */
279 for(i
=0; i
<countSetRanges
; ++i
) {
280 start
=setRanges
[i
].start
;
281 limit
=setRanges
[i
].limit
;
282 value
=setRanges
[i
].value
;
283 overwrite
=setRanges
[i
].overwrite
;
284 if((limit
-start
)==1 && overwrite
) {
285 ok
&=utrie_set32(newTrie
, start
, value
);
287 ok
&=utrie_setRange32(newTrie
, start
, limit
, value
, overwrite
);
291 log_err("error: setting values into a trie failed (%s)\n", testName
);
295 /* verify that all these values are in the new Trie */
297 for(i
=0; i
<countCheckRanges
; ++i
) {
298 limit
=checkRanges
[i
].limit
;
299 value
=checkRanges
[i
].value
;
302 if(value
!=utrie_get32(newTrie
, start
, NULL
)) {
303 log_err("error: newTrie(%s)[U+%04lx]==0x%lx instead of 0x%lx\n",
304 testName
, start
, utrie_get32(newTrie
, start
, NULL
), value
);
311 getFoldingOffset
=_testFoldingOffset32
;
313 getFoldingOffset
=_testFoldingOffset16
;
316 errorCode
=U_ZERO_ERROR
;
317 length
=utrie_serialize(newTrie
, storage
, DEFAULT_STORAGE_SIZE
,
318 dataIs32
? _testFoldedValue32
: _testFoldedValue16
,
321 if(U_FAILURE(errorCode
)) {
322 log_err("error: utrie_serialize(%s) failed: %s\n", testName
, u_errorName(errorCode
));
323 utrie_close(newTrie
);
327 /* test linear Latin-1 range from utrie_getData() */
332 data
=utrie_getData(newTrie
, &dataLength
);
334 for(i
=0; i
<countCheckRanges
&& start
<=0xff; ++i
) {
335 limit
=checkRanges
[i
].limit
;
336 value
=checkRanges
[i
].value
;
338 while(start
<limit
&& start
<=0xff) {
339 if(value
!=data
[UTRIE_DATA_BLOCK_LENGTH
+start
]) {
340 log_err("error: newTrie(%s).latin1Data[U+%04lx]==0x%lx instead of 0x%lx\n",
341 testName
, start
, data
[UTRIE_DATA_BLOCK_LENGTH
+start
], value
);
348 utrie_close(newTrie
);
350 errorCode
=U_ZERO_ERROR
;
351 if(!utrie_unserialize(&trie
, storage
, length
, &errorCode
)) {
352 log_err("error: utrie_unserialize() failed, %s\n", u_errorName(errorCode
));
355 trie
.getFoldingOffset
=getFoldingOffset
;
357 if(dataIs32
!=(trie
.data32
!=NULL
)) {
358 log_err("error: trie serialization (%s) did not preserve 32-bitness\n", testName
);
360 if(latin1Linear
!=trie
.isLatin1Linear
) {
361 log_err("error: trie serialization (%s) did not preserve Latin-1-linearity\n", testName
);
364 /* verify that all these values are in the unserialized Trie */
366 for(i
=0; i
<countCheckRanges
; ++i
) {
367 limit
=checkRanges
[i
].limit
;
368 value
=checkRanges
[i
].value
;
371 /* skip surrogates */
379 value2
=UTRIE_GET32_FROM_BMP(&trie
, start
);
381 value2
=UTRIE_GET16_FROM_BMP(&trie
, start
);
384 log_err("error: unserialized trie(%s).fromBMP(U+%04lx)==0x%lx instead of 0x%lx\n",
385 testName
, start
, value2
, value
);
387 if(!UTF_IS_LEAD(start
)) {
389 value2
=UTRIE_GET32_FROM_LEAD(&trie
, start
);
391 value2
=UTRIE_GET16_FROM_LEAD(&trie
, start
);
394 log_err("error: unserialized trie(%s).fromLead(U+%04lx)==0x%lx instead of 0x%lx\n",
395 testName
, start
, value2
, value
);
400 UTRIE_GET32(&trie
, start
, value2
);
402 UTRIE_GET16(&trie
, start
, value2
);
405 log_err("error: unserialized trie(%s).get(U+%04lx)==0x%lx instead of 0x%lx\n",
406 testName
, start
, value2
, value
);
412 /* enumerate and verify all ranges */
413 enumRanges
=checkRanges
+1;
414 utrie_enum(&trie
, _testEnumValue
, _testEnumRange
, &enumRanges
);
416 /* test linear Latin-1 range */
417 if(trie
.isLatin1Linear
) {
418 if(trie
.data32
!=NULL
) {
419 const uint32_t *latin1
=UTRIE_GET32_LATIN1(&trie
);
421 for(start
=0; start
<0x100; ++start
) {
422 if(latin1
[start
]!=UTRIE_GET32_FROM_LEAD(&trie
, start
)) {
423 log_err("error: (%s) trie.latin1[U+%04lx]=0x%lx!=0x%lx=trie.get32(U+%04lx)\n",
424 testName
, start
, latin1
[start
], UTRIE_GET32_FROM_LEAD(&trie
, start
), start
);
428 const uint16_t *latin1
=UTRIE_GET16_LATIN1(&trie
);
430 for(start
=0; start
<0x100; ++start
) {
431 if(latin1
[start
]!=UTRIE_GET16_FROM_LEAD(&trie
, start
)) {
432 log_err("error: (%s) trie.latin1[U+%04lx]=0x%lx!=0x%lx=trie.get16(U+%04lx)\n",
433 testName
, start
, latin1
[start
], UTRIE_GET16_FROM_LEAD(&trie
, start
), start
);
439 testTrieIteration(testName
, &trie
, checkRanges
, countCheckRanges
);
444 testTrieRanges(const char *testName
,
445 const SetRange setRanges
[], int32_t countSetRanges
,
446 const CheckRange checkRanges
[], int32_t countCheckRanges
,
447 UBool dataIs32
, UBool latin1Linear
) {
449 double bogus
; /* needed for aligining the storage */
450 uint8_t storage
[32768];
452 UTrieGetFoldingOffset
*getFoldingOffset
;
453 UNewTrieGetFoldedValue
*getFoldedValue
;
454 const CheckRange
*enumRanges
;
457 uint32_t value
, value2
;
458 UChar32 start
, limit
;
460 UErrorCode errorCode
;
463 log_verbose("\ntesting Trie '%s'\n", testName
);
464 newTrie
=utrie_open(NULL
, NULL
, 2000,
465 checkRanges
[0].value
, checkRanges
[0].value
,
468 /* set values from setRanges[] */
470 for(i
=0; i
<countSetRanges
; ++i
) {
471 start
=setRanges
[i
].start
;
472 limit
=setRanges
[i
].limit
;
473 value
=setRanges
[i
].value
;
474 overwrite
=setRanges
[i
].overwrite
;
475 if((limit
-start
)==1 && overwrite
) {
476 ok
&=utrie_set32(newTrie
, start
, value
);
478 ok
&=utrie_setRange32(newTrie
, start
, limit
, value
, overwrite
);
482 log_err("error: setting values into a trie failed (%s)\n", testName
);
486 /* verify that all these values are in the new Trie */
488 for(i
=0; i
<countCheckRanges
; ++i
) {
489 limit
=checkRanges
[i
].limit
;
490 value
=checkRanges
[i
].value
;
493 if(value
!=utrie_get32(newTrie
, start
, NULL
)) {
494 log_err("error: newTrie(%s)[U+%04lx]==0x%lx instead of 0x%lx\n",
495 testName
, start
, utrie_get32(newTrie
, start
, NULL
), value
);
502 getFoldingOffset
=_testFoldingOffset32
;
503 getFoldedValue
=_testFoldedValue32
;
505 getFoldingOffset
=_testFoldingOffset16
;
506 getFoldedValue
=_testFoldedValue16
;
510 * code coverage for utrie.c/defaultGetFoldedValue(),
511 * pick some combination of parameters for selecting the UTrie defaults
513 if(!dataIs32
&& latin1Linear
) {
514 getFoldingOffset
=NULL
;
518 errorCode
=U_ZERO_ERROR
;
519 length
=utrie_serialize(newTrie
, storageHolder
.storage
, sizeof(storageHolder
.storage
),
523 if(U_FAILURE(errorCode
)) {
524 log_err("error: utrie_serialize(%s) failed: %s\n", testName
, u_errorName(errorCode
));
525 utrie_close(newTrie
);
528 if (length
>= (int32_t)sizeof(storageHolder
.storage
)) {
529 log_err("error: utrie_serialize(%s) needs more memory\n", testName
);
530 utrie_close(newTrie
);
534 /* test linear Latin-1 range from utrie_getData() */
539 data
=utrie_getData(newTrie
, &dataLength
);
541 for(i
=0; i
<countCheckRanges
&& start
<=0xff; ++i
) {
542 limit
=checkRanges
[i
].limit
;
543 value
=checkRanges
[i
].value
;
545 while(start
<limit
&& start
<=0xff) {
546 if(value
!=data
[UTRIE_DATA_BLOCK_LENGTH
+start
]) {
547 log_err("error: newTrie(%s).latin1Data[U+%04lx]==0x%lx instead of 0x%lx\n",
548 testName
, start
, data
[UTRIE_DATA_BLOCK_LENGTH
+start
], value
);
555 utrie_close(newTrie
);
557 errorCode
=U_ZERO_ERROR
;
558 if(!utrie_unserialize(&trie
, storageHolder
.storage
, length
, &errorCode
)) {
559 log_err("error: utrie_unserialize() failed, %s\n", u_errorName(errorCode
));
562 if(getFoldingOffset
!=NULL
) {
563 trie
.getFoldingOffset
=getFoldingOffset
;
566 if(dataIs32
!=(trie
.data32
!=NULL
)) {
567 log_err("error: trie serialization (%s) did not preserve 32-bitness\n", testName
);
569 if(latin1Linear
!=trie
.isLatin1Linear
) {
570 log_err("error: trie serialization (%s) did not preserve Latin-1-linearity\n", testName
);
573 /* verify that all these values are in the unserialized Trie */
575 for(i
=0; i
<countCheckRanges
; ++i
) {
576 limit
=checkRanges
[i
].limit
;
577 value
=checkRanges
[i
].value
;
580 /* skip surrogates */
588 value2
=UTRIE_GET32_FROM_BMP(&trie
, start
);
590 value2
=UTRIE_GET16_FROM_BMP(&trie
, start
);
593 log_err("error: unserialized trie(%s).fromBMP(U+%04lx)==0x%lx instead of 0x%lx\n",
594 testName
, start
, value2
, value
);
596 if(!UTF_IS_LEAD(start
)) {
598 value2
=UTRIE_GET32_FROM_LEAD(&trie
, start
);
600 value2
=UTRIE_GET16_FROM_LEAD(&trie
, start
);
603 log_err("error: unserialized trie(%s).fromLead(U+%04lx)==0x%lx instead of 0x%lx\n",
604 testName
, start
, value2
, value
);
609 UTRIE_GET32(&trie
, start
, value2
);
611 UTRIE_GET16(&trie
, start
, value2
);
614 log_err("error: unserialized trie(%s).get(U+%04lx)==0x%lx instead of 0x%lx\n",
615 testName
, start
, value2
, value
);
621 /* enumerate and verify all ranges */
622 enumRanges
=checkRanges
+1;
623 utrie_enum(&trie
, _testEnumValue
, _testEnumRange
, &enumRanges
);
625 /* test linear Latin-1 range */
626 if(trie
.isLatin1Linear
) {
627 if(trie
.data32
!=NULL
) {
628 const uint32_t *latin1
=UTRIE_GET32_LATIN1(&trie
);
630 for(start
=0; start
<0x100; ++start
) {
631 if(latin1
[start
]!=UTRIE_GET32_FROM_LEAD(&trie
, start
)) {
632 log_err("error: (%s) trie.latin1[U+%04lx]=0x%lx!=0x%lx=trie.get32(U+%04lx)\n",
633 testName
, start
, latin1
[start
], UTRIE_GET32_FROM_LEAD(&trie
, start
), start
);
637 const uint16_t *latin1
=UTRIE_GET16_LATIN1(&trie
);
639 for(start
=0; start
<0x100; ++start
) {
640 if(latin1
[start
]!=UTRIE_GET16_FROM_LEAD(&trie
, start
)) {
641 log_err("error: (%s) trie.latin1[U+%04lx]=0x%lx!=0x%lx=trie.get16(U+%04lx)\n",
642 testName
, start
, latin1
[start
], UTRIE_GET16_FROM_LEAD(&trie
, start
), start
);
648 testTrieIteration(testName
, &trie
, checkRanges
, countCheckRanges
);
652 testTrieRanges2(const char *testName
,
653 const SetRange setRanges
[], int32_t countSetRanges
,
654 const CheckRange checkRanges
[], int32_t countCheckRanges
,
658 testTrieRanges(testName
,
659 setRanges
, countSetRanges
,
660 checkRanges
, countCheckRanges
,
662 testTrieRangesWithMalloc(testName
,
663 setRanges
, countSetRanges
,
664 checkRanges
, countCheckRanges
,
667 uprv_strcpy(name
, testName
);
668 uprv_strcat(name
, "-latin1Linear");
670 setRanges
, countSetRanges
,
671 checkRanges
, countCheckRanges
,
673 testTrieRangesWithMalloc(name
,
674 setRanges
, countSetRanges
,
675 checkRanges
, countCheckRanges
,
680 testTrieRanges4(const char *testName
,
681 const SetRange setRanges
[], int32_t countSetRanges
,
682 const CheckRange checkRanges
[], int32_t countCheckRanges
) {
685 uprv_strcpy(name
, testName
);
686 uprv_strcat(name
, ".32");
687 testTrieRanges2(name
,
688 setRanges
, countSetRanges
,
689 checkRanges
, countCheckRanges
,
692 uprv_strcpy(name
, testName
);
693 uprv_strcat(name
, ".16");
694 testTrieRanges2(name
,
695 setRanges
, countSetRanges
,
696 checkRanges
, countCheckRanges
,
700 /* test data ----------------------------------------------------------------*/
702 /* set consecutive ranges, even with value 0 */
703 static const SetRange
706 {0x20, 0xa7, 0x1234, FALSE
},
707 {0xa7, 0x3400, 0, FALSE
},
708 {0x3400, 0x9fa6, 0x6162, FALSE
},
709 {0x9fa6, 0xda9e, 0x3132, FALSE
},
710 {0xdada, 0xeeee, 0x87ff, FALSE
}, /* try to disrupt _testFoldingOffset16() */
711 {0xeeee, 0x11111, 1, FALSE
},
712 {0x11111, 0x44444, 0x6162, FALSE
},
713 {0x44444, 0x60003, 0, FALSE
},
714 {0xf0003, 0xf0004, 0xf, FALSE
},
715 {0xf0004, 0xf0006, 0x10, FALSE
},
716 {0xf0006, 0xf0007, 0x11, FALSE
},
717 {0xf0007, 0xf0020, 0x12, FALSE
},
718 {0xf0020, 0x110000, 0, FALSE
}
721 static const CheckRange
723 {0, 0}, /* dummy start range to make _testEnumRange() simpler */
741 /* set some interesting overlapping ranges */
742 static const SetRange
744 {0x21, 0x7f, 0x5555, TRUE
},
745 {0x2f800,0x2fedc, 0x7a, TRUE
},
746 {0x72, 0xdd, 3, TRUE
},
747 {0xdd, 0xde, 4, FALSE
},
748 {0x201, 0x220, 6, TRUE
}, /* 3 consecutive blocks with the same pattern but discontiguous value ranges */
749 {0x221, 0x240, 6, TRUE
},
750 {0x241, 0x260, 6, TRUE
},
751 {0x2f987,0x2fa98, 5, TRUE
},
752 {0x2f777,0x2f833, 0, TRUE
},
753 {0x2f900,0x2ffee, 1, FALSE
},
754 {0x2ffee,0x2ffef, 2, TRUE
}
757 static const CheckRange
759 {0, 0}, /* dummy start range to make _testEnumRange() simpler */
779 /* use a non-zero initial value */
780 static const SetRange
782 {0x31, 0xa4, 1, FALSE
},
783 {0x3400, 0x6789, 2, FALSE
},
784 {0x30000,0x34567,9, TRUE
},
785 {0x45678,0x56789,3, TRUE
}
788 static const CheckRange
790 {0, 9}, /* dummy start range, also carries the initial value */
802 testTrieRanges4("set1",
803 setRanges1
, ARRAY_LENGTH(setRanges1
),
804 checkRanges1
, ARRAY_LENGTH(checkRanges1
));
805 testTrieRanges4("set2-overlap",
806 setRanges2
, ARRAY_LENGTH(setRanges2
),
807 checkRanges2
, ARRAY_LENGTH(checkRanges2
));
808 testTrieRanges4("set3-initial-9",
809 setRanges3
, ARRAY_LENGTH(setRanges3
),
810 checkRanges3
, ARRAY_LENGTH(checkRanges3
));
813 /* test utrie_unserializeDummy() -------------------------------------------- */
815 static int32_t U_CALLCONV
816 dummyGetFoldingOffset(uint32_t data
) {
817 return -1; /* never get non-initialValue data for supplementary code points */
821 dummyTest(UBool make16BitTrie
) {
822 int32_t mem
[UTRIE_DUMMY_SIZE
/4];
825 UErrorCode errorCode
;
828 uint32_t value
, initialValue
, leadUnitValue
;
832 leadUnitValue
=0xaffe;
834 initialValue
=0x01234567;
835 leadUnitValue
=0x89abcdef;
838 errorCode
=U_ZERO_ERROR
;
839 utrie_unserializeDummy(&trie
, mem
, sizeof(mem
), initialValue
, leadUnitValue
, make16BitTrie
, &errorCode
);
840 if(U_FAILURE(errorCode
)) {
841 log_err("utrie_unserializeDummy(make16BitTrie=%d) failed - %s\n", make16BitTrie
, u_errorName(errorCode
));
844 trie
.getFoldingOffset
=dummyGetFoldingOffset
;
846 /* test that all code points have initialValue */
847 for(c
=0; c
<=0x10ffff; ++c
) {
849 UTRIE_GET16(&trie
, c
, value
);
851 UTRIE_GET32(&trie
, c
, value
);
853 if(value
!=initialValue
) {
854 log_err("UTRIE_GET%s(dummy, U+%04lx)=0x%lx instead of 0x%lx\n",
855 make16BitTrie
? "16" : "32", (long)c
, (long)value
, (long)initialValue
);
859 /* test that the lead surrogate code units have leadUnitValue */
860 for(c
=0xd800; c
<=0xdbff; ++c
) {
862 value
=UTRIE_GET16_FROM_LEAD(&trie
, c
);
864 value
=UTRIE_GET32_FROM_LEAD(&trie
, c
);
866 if(value
!=leadUnitValue
) {
867 log_err("UTRIE_GET%s_FROM_LEAD(dummy, U+%04lx)=0x%lx instead of 0x%lx\n",
868 make16BitTrie
? "16" : "32", (long)c
, (long)value
, (long)leadUnitValue
);
874 DummyTrieTest(void) {
880 addTrieTest(TestNode
** root
);
883 addTrieTest(TestNode
** root
) {
884 addTest(root
, &TrieTest
, "tsutil/trietest/TrieTest");
885 addTest(root
, &DummyTrieTest
, "tsutil/trietest/DummyTrieTest");