1 /** 2 * Copyright (c) 1999-2012, International Business Machines Corporation and 3 * others. All Rights Reserved. 4 * 5 * Test for source/i18n/collunsafe.h 6 */ 7 8 #include <stdio.h> 9 #include "unicode/ucol.h" 10 #include "unicode/uniset.h" 11 #include "unicode/coll.h" 12 #include "collation.h" 13 14 #include "collunsafe.h" 15 16 17 int main(int argc, const char *argv[]) { 18 puts("verify"); 19 UErrorCode errorCode = U_ZERO_ERROR; 20 #if defined (COLLUNSAFE_PATTERN) 21 puts("verify pattern"); 22 const UnicodeString unsafeBackwardPattern(FALSE, collunsafe_pattern, collunsafe_len); 23 fprintf(stderr, "\n -- pat '%c%c%c%c%c'\n", 24 collunsafe_pattern[0], 25 collunsafe_pattern[1], 26 collunsafe_pattern[2], 27 collunsafe_pattern[3], 28 collunsafe_pattern[4]); 29 if(U_SUCCESS(errorCode)) { 30 UnicodeSet us(unsafeBackwardPattern, errorCode); 31 fprintf(stderr, "\n%s:%d: err creating set %s\n", __FILE__, __LINE__, u_errorName(errorCode)); 32 } 33 #endif 34 35 #if defined (COLLUNSAFE_RANGE) 36 { 37 puts("verify range"); 38 UnicodeSet u; 39 for(int32_t i=0;i<unsafe_rangeCount*2;i+=2) { 40 u.add(unsafe_ranges[i+0],unsafe_ranges[i+1]); 41 } 42 printf("Finished with %d ranges\n", u.getRangeCount()); 43 } 44 #endif 45 46 #if defined (COLLUNSAFE_SERIALIZE) 47 { 48 puts("verify serialize"); 49 UnicodeSet u(unsafe_serializedData, unsafe_serializedCount, UnicodeSet::kSerialized, errorCode); 50 fprintf(stderr, "\n%s:%d: err creating set %s\n", __FILE__, __LINE__, u_errorName(errorCode)); 51 printf("Finished deserialize with %d ranges\n", u.getRangeCount()); 52 } 53 #endif 54 // if(tailoring.unsafeBackwardSet == NULL) { 55 // errorCode = U_MEMORY_ALLOCATION_ERROR; 56 // fprintf(stderr, "\n%s:%d: err %s\n", __FILE__, __LINE__, u_errorName(errorCode)); 57 // } 58 puts("verify col UCA"); 59 if(U_SUCCESS(errorCode)) { 60 Collator *col = Collator::createInstance(Locale::getEnglish(), errorCode); 61 fprintf(stderr, "\n%s:%d: err %s creating collator\n", __FILE__, __LINE__, u_errorName(errorCode)); 62 } 63 64 if(U_FAILURE(errorCode)) { 65 return 1; 66 } else { 67 return 0; 68 } 69 } 70