OLD | NEW |
(Empty) | |
| 1 /******************************************************************** |
| 2 * COPYRIGHT: |
| 3 * Copyright (c) 1999-2006, International Business Machines Corporation and |
| 4 * others. All Rights Reserved. |
| 5 ********************************************************************/ |
| 6 #include "unicode/utypes.h" |
| 7 #include "unicode/ustring.h" |
| 8 #include "unicode/ctest.h" |
| 9 #include "unicode/ucnv.h" |
| 10 |
| 11 void TestEuroRegression(void); |
| 12 void addTestEuroRegression(TestNode** root); |
| 13 |
| 14 #if !UCONFIG_NO_LEGACY_CONVERSION |
| 15 void addTestEuroRegression(TestNode** root) |
| 16 { |
| 17 addTest(root, &TestEuroRegression, "tsconv/eurocreg/TestEuroRegression"); |
| 18 } |
| 19 |
| 20 /* |
| 21 * The table below lists codepages that are supposed to have roundtrip mappings
for |
| 22 * the U+20AC Euro sign. |
| 23 * |
| 24 * Changes made 2000nov28 and marked as such are due to the following: |
| 25 * |
| 26 * After updating all ibm-*.ucm files with precise fallback indicators (|0, |1,
|3), |
| 27 * some of these codepages failed the Euro regression test. |
| 28 * This means that the actuall mappings changed when only the preciseness of fal
lback |
| 29 * mappings should have changed. |
| 30 * My (Markus) suspicion is that some files got Euro sign mappings added manuall
y, |
| 31 * changing their contents compared to the NLTC (IBM Toronto codepage database)
definition. |
| 32 * Such changes are highly undesirable because they effectively define new codep
ages. |
| 33 * Codepage mapping files with "ibm-*.ucm" should always exactly match the files |
| 34 * from the IBM codepage database. |
| 35 * (If there are several mappings with the same number, then we choose the |
| 36 * default mappings with Private-Use Area assignments.) |
| 37 * |
| 38 * Also, in the past, some aliases were set such that e.g. cp850 became an alias
for ibm-858. |
| 39 * This followed the practice of OS/2 that uses the old codepage number 850 for
the new |
| 40 * codepage 858, with the main difference being the additional Euro sign. |
| 41 * However, we have documented that the "cp" prefix should be used for Microsoft
-compatible |
| 42 * codepages, and Microsoft Windows 2000's codepage 850 does not contain a Euro
sign mapping. |
| 43 * Therefore, cp850 must not support the Euro sign. |
| 44 * In these cases, I have changed the codepage name here to point to a newer cod
epage with the |
| 45 * Euro sign, using its new name. |
| 46 * I could not find such "updates" for codepages 1362 and 1363 - we might want t
o supply them later. |
| 47 */ |
| 48 |
| 49 static const char convertersToCheck[][15] = { |
| 50 "cp1250", |
| 51 "cp1251", |
| 52 "cp1252", |
| 53 "cp1254", |
| 54 "cp1255", |
| 55 "cp1256", |
| 56 "cp1257", |
| 57 "cp1258", |
| 58 "ibm1140", |
| 59 "ibm1142", |
| 60 "ibm1143", |
| 61 "ibm1144", |
| 62 "ibm1145", |
| 63 "ibm1146", |
| 64 "ibm1147", |
| 65 "ibm1148", |
| 66 "ibm1149", |
| 67 "ibm1153", |
| 68 "ibm1154", |
| 69 "ibm1155", |
| 70 "ibm1156", |
| 71 "ibm1157", |
| 72 "ibm1158", |
| 73 /*"ibm-1159",*/ /* removed 2003Apr17 */ |
| 74 "ibm12712", |
| 75 "ibm16804", |
| 76 "ibm-1160", |
| 77 "ibm-1162", |
| 78 "ibm-1164", |
| 79 |
| 80 "ibm-858", /* was "cp850" changed 2000nov28 */ |
| 81 /* duplicate "cp850" removed 2000nov28 */ |
| 82 /*"ibm-9049",*/ /* was "cp857" changed 2002nov25 */ |
| 83 "ibm-12712", /* was "cp424" changed 2000nov28 */ |
| 84 "ibm-4899", /* was "cp803" changed 2000nov28 */ |
| 85 "ibm-867", /* was "cp862" changed 2002nov25 */ |
| 86 "cp1258", |
| 87 "windows-950", |
| 88 "cp1253", |
| 89 /* "cp819", |
| 90 "cp13488",*/ |
| 91 "ibm-4971", |
| 92 /*"ibm-9061",*/ /* was "cp869" changed 2002nov25 */ |
| 93 /* "cp813",*/ |
| 94 /*"ibm-9044",*/ /* was "cp852" changed 2002nov25 */ |
| 95 /*"ibm-872",*/ /* was "cp855" changed 2002nov25 */ |
| 96 /*"ibm-808",*/ /* was "cp866" changed 2002nov25 */ |
| 97 /* "cp1131", |
| 98 "cp1125",*/ |
| 99 "ibm-902", /* was "cp922" changed 2003jan08 */ |
| 100 "ibm-901", /* was "cp921" changed 2003jan09 */ |
| 101 /*"ibm-17248",*/ /* was "cp864" changed 2002nov25 */ |
| 102 /*"cp1008", |
| 103 "cp1046",*/ |
| 104 /* "cp9066", |
| 105 "cp1129",*/ |
| 106 "ibm-5123", /* was "cp1027" changed 2003jan08 */ |
| 107 /* "cp300",*/ |
| 108 /* "cp4930",*/ |
| 109 "ibm-1364", |
| 110 /* "cp1362" removed 2000nov28 */ |
| 111 "cp1363", |
| 112 /* "cp1114", removed 2002jul3 |
| 113 "cp947", removed 2002jul3 */ |
| 114 "gb18030", |
| 115 ""}; |
| 116 |
| 117 UBool isEuroAware(UConverter*); |
| 118 |
| 119 void TestEuroRegression() |
| 120 { |
| 121 int32_t i=0; |
| 122 |
| 123 do |
| 124 { |
| 125 UErrorCode err = U_ZERO_ERROR; |
| 126 UConverter* myConv = ucnv_open(convertersToCheck[i], &err); |
| 127 if (U_FAILURE(err)&&convertersToCheck[i][0]) |
| 128 log_data_err("%s \tMISSING [%s]\n", convertersToCheck[i], u_errorNa
me(err)); |
| 129 else |
| 130 { |
| 131 if (isEuroAware(myConv)) |
| 132 log_verbose("%s \tsupports euro\n", convertersToCheck[i]); |
| 133 else |
| 134 log_err("%s \tDOES NOT support euro\n", convertersToCheck[i]); |
| 135 ucnv_close(myConv); |
| 136 } |
| 137 } while (convertersToCheck[++i][0]); |
| 138 } |
| 139 |
| 140 UBool isEuroAware(UConverter* myConv) |
| 141 { |
| 142 static const UChar euroString[2] = { 0x20AC, 0x0000 }; |
| 143 char target[20]; |
| 144 UChar euroBack[2]; |
| 145 int32_t targetSize, euroBackSize; |
| 146 UErrorCode err = U_ZERO_ERROR; |
| 147 /*const char* myName = ucnv_getName(myConv, &err);*/ |
| 148 |
| 149 targetSize = ucnv_fromUChars(myConv, |
| 150 target, |
| 151 sizeof(target), |
| 152 euroString, |
| 153 -1, |
| 154 &err); |
| 155 if (U_FAILURE(err)) |
| 156 { |
| 157 log_err("Failure Occured in ucnv_fromUChars euro roundtrip test\n"); |
| 158 return FALSE; |
| 159 } |
| 160 euroBackSize = ucnv_toUChars(myConv, |
| 161 euroBack, |
| 162 2, |
| 163 target, |
| 164 targetSize, |
| 165 &err); |
| 166 if (U_FAILURE(err)) |
| 167 { |
| 168 log_err("Failure Occured in ucnv_toUChars euro roundtrip test\n"); |
| 169 return FALSE; |
| 170 } |
| 171 if (u_strcmp(euroString, euroBack)) |
| 172 { |
| 173 /* log_err("%s FAILED Euro rountrip\n", myName);*/ |
| 174 return FALSE; |
| 175 } |
| 176 else |
| 177 { |
| 178 /* log_verbose("%s PASSED Euro rountrip\n", myName);*/ |
| 179 return TRUE; |
| 180 } |
| 181 |
| 182 } |
| 183 #else |
| 184 void addTestEuroRegression(TestNode** root) |
| 185 { |
| 186 /* test nothing... */ |
| 187 } |
| 188 #endif |
OLD | NEW |