]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/gencolusb/verify_uset.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 * Copyright (c) 1999-2012, International Business Machines Corporation and
5 * others. All Rights Reserved.
7 * Test for source/i18n/collunsafe.h
11 #include "unicode/ucol.h"
12 #include "unicode/uniset.h"
13 #include "unicode/coll.h"
14 #include "collation.h"
16 #include "collunsafe.h"
19 int main(int argc
, const char *argv
[]) {
21 UErrorCode errorCode
= U_ZERO_ERROR
;
22 #if defined (COLLUNSAFE_PATTERN)
23 puts("verify pattern");
24 const UnicodeString
unsafeBackwardPattern(FALSE
, collunsafe_pattern
, collunsafe_len
);
25 fprintf(stderr
, "\n -- pat '%c%c%c%c%c'\n",
26 collunsafe_pattern
[0],
27 collunsafe_pattern
[1],
28 collunsafe_pattern
[2],
29 collunsafe_pattern
[3],
30 collunsafe_pattern
[4]);
31 if(U_SUCCESS(errorCode
)) {
32 UnicodeSet
us(unsafeBackwardPattern
, errorCode
);
33 fprintf(stderr
, "\n%s:%d: err creating set %s\n", __FILE__
, __LINE__
, u_errorName(errorCode
));
37 #if defined (COLLUNSAFE_RANGE)
41 for(int32_t i
=0;i
<unsafe_rangeCount
*2;i
+=2) {
42 u
.add(unsafe_ranges
[i
+0],unsafe_ranges
[i
+1]);
44 printf("Finished with %d ranges\n", u
.getRangeCount());
48 #if defined (COLLUNSAFE_SERIALIZE)
50 puts("verify serialize");
51 UnicodeSet
u(unsafe_serializedData
, unsafe_serializedCount
, UnicodeSet::kSerialized
, errorCode
);
52 fprintf(stderr
, "\n%s:%d: err creating set %s\n", __FILE__
, __LINE__
, u_errorName(errorCode
));
53 printf("Finished deserialize with %d ranges\n", u
.getRangeCount());
56 // if(tailoring.unsafeBackwardSet == NULL) {
57 // errorCode = U_MEMORY_ALLOCATION_ERROR;
58 // fprintf(stderr, "\n%s:%d: err %s\n", __FILE__, __LINE__, u_errorName(errorCode));
60 puts("verify col UCA");
61 if(U_SUCCESS(errorCode
)) {
62 Collator
*col
= Collator::createInstance(Locale::getEnglish(), errorCode
);
63 fprintf(stderr
, "\n%s:%d: err %s creating collator\n", __FILE__
, __LINE__
, u_errorName(errorCode
));
66 if(U_FAILURE(errorCode
)) {