blob: fe2093c056ace57463a39ac4b8c170c21ae18726 [file] [log] [blame]
Jungshik Shin87232d82017-05-13 21:10:13 -07001// © 2016 and later: Unicode, Inc. and others.
Jungshik Shin5feb9ad2016-10-21 12:52:48 -07002// License & terms of use: http://www.unicode.org/copyright.html
Jungshik Shin70f82502016-01-29 00:32:36 -08003/**
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");
Frank Tang1f164ee2022-11-08 12:31:27 -080024 const UnicodeString unsafeBackwardPattern(false, collunsafe_pattern, collunsafe_len);
Jungshik Shin70f82502016-01-29 00:32:36 -080025 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}