]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/gencolusb/verify_uset.cpp
ICU-59117.0.1.tar.gz
[apple/icu.git] / icuSources / tools / gencolusb / verify_uset.cpp
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
2ca993e8
A
3/**
4 * Copyright (c) 1999-2012, International Business Machines Corporation and
5 * others. All Rights Reserved.
6 *
7 * Test for source/i18n/collunsafe.h
8 */
9
10#include <stdio.h>
11#include "unicode/ucol.h"
12#include "unicode/uniset.h"
13#include "unicode/coll.h"
14#include "collation.h"
15
16#include "collunsafe.h"
17
18
19int main(int argc, const char *argv[]) {
20 puts("verify");
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));
34 }
35#endif
36
37#if defined (COLLUNSAFE_RANGE)
38 {
39 puts("verify range");
40 UnicodeSet u;
41 for(int32_t i=0;i<unsafe_rangeCount*2;i+=2) {
42 u.add(unsafe_ranges[i+0],unsafe_ranges[i+1]);
43 }
44 printf("Finished with %d ranges\n", u.getRangeCount());
45 }
46#endif
47
48#if defined (COLLUNSAFE_SERIALIZE)
49 {
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());
54 }
55#endif
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));
59 // }
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));
64 }
65
66 if(U_FAILURE(errorCode)) {
67 return 1;
68 } else {
69 return 0;
70 }
71}