]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/cintltst/spreptst.c
ICU-6.2.7.tar.gz
[apple/icu.git] / icuSources / test / cintltst / spreptst.c
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 2003, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 * file name: spreptst.c
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2003jul11
14 * created by: Ram Viswanadha
15 */
16 #include <stdlib.h>
17 #include <string.h>
18 #include "unicode/utypes.h"
19
20 #if !UCONFIG_NO_IDNA
21
22 #include "unicode/ustring.h"
23 #include "unicode/usprep.h"
24 #include "cintltst.h"
25 #include "nfsprep.h"
26
27
28 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
29
30 void addUStringPrepTest(TestNode** root);
31 void doStringPrepTest(const char* binFileName, const char* txtFileName,
32 int32_t options, UErrorCode* errorCode);
33
34 static void Test_nfs4_cs_prep_data(void);
35 static void Test_nfs4_cis_prep_data(void);
36 static void Test_nfs4_mixed_prep_data(void);
37 static void Test_nfs4_cs_prep(void);
38 static void Test_nfs4_cis_prep(void);
39 static void Test_nfs4_mixed_prep(void);
40
41 void
42 addUStringPrepTest(TestNode** root)
43 {
44 addTest(root, &Test_nfs4_cs_prep_data, "spreptst/Test_nfs4_cs_prep_data");
45 addTest(root, &Test_nfs4_cis_prep_data, "spreptst/Test_nfs4_cis_prep_data");
46 addTest(root, &Test_nfs4_mixed_prep_data, "spreptst/Test_nfs4_mixed_prep_data");
47 addTest(root, &Test_nfs4_cs_prep, "spreptst/Test_nfs4_cs_prep");
48 addTest(root, &Test_nfs4_cis_prep, "spreptst/Test_nfs4_cis_prep");
49 addTest(root, &Test_nfs4_mixed_prep, "spreptst/Test_nfs4_mixed_prep");
50 }
51
52 static void
53 Test_nfs4_cs_prep_data(void){
54 UErrorCode errorCode = U_ZERO_ERROR;
55 log_verbose("Testing nfs4_cs_prep_ci.txt\n");
56 doStringPrepTest("nfscsi","nfs4_cs_prep_ci.txt", USPREP_DEFAULT, &errorCode);
57
58 log_verbose("Testing nfs4_cs_prep_cs.txt\n");
59 errorCode = U_ZERO_ERROR;
60 doStringPrepTest("nfscss","nfs4_cs_prep_cs.txt", USPREP_DEFAULT, &errorCode);
61
62
63 }
64 static void
65 Test_nfs4_cis_prep_data(void){
66 UErrorCode errorCode = U_ZERO_ERROR;
67 log_verbose("Testing nfs4_cis_prep.txt\n");
68 doStringPrepTest("nfscis","nfs4_cis_prep.txt", USPREP_DEFAULT, &errorCode);
69 }
70 static void
71 Test_nfs4_mixed_prep_data(void){
72 UErrorCode errorCode = U_ZERO_ERROR;
73 log_verbose("Testing nfs4_mixed_prep_s.txt\n");
74 doStringPrepTest("nfsmxs","nfs4_mixed_prep_s.txt", USPREP_DEFAULT, &errorCode);
75
76 errorCode = U_ZERO_ERROR;
77 log_verbose("Testing nfs4_mixed_prep_p.txt\n");
78 doStringPrepTest("nfsmxp","nfs4_mixed_prep_p.txt", USPREP_DEFAULT, &errorCode);
79
80 }
81
82 static struct ConformanceTestCases
83 {
84 const char *comment;
85 const char *in;
86 const char *out;
87 const char *profile;
88 UErrorCode expectedStatus;
89 }
90 conformanceTestCases[] =
91 {
92
93 {/*0*/
94 "Case folding ASCII U+0043 U+0041 U+0046 U+0045",
95 "\x43\x41\x46\x45", "\x63\x61\x66\x65",
96 "nfs4_cis_prep",
97 U_ZERO_ERROR
98
99 },
100 {/*1*/
101 "Case folding 8bit U+00DF (german sharp s)",
102 "\xC3\x9F", "\x73\x73",
103 "nfs4_cis_prep",
104 U_ZERO_ERROR
105 },
106 {/*2*/
107 "Non-ASCII multibyte space character U+1680",
108 "\xE1\x9A\x80", NULL,
109 "nfs4_cis_prep",
110 U_STRINGPREP_PROHIBITED_ERROR
111 },
112 {/*3*/
113 "Non-ASCII 8bit control character U+0085",
114 "\xC2\x85", NULL,
115 "nfs4_cis_prep",
116 U_STRINGPREP_PROHIBITED_ERROR
117 },
118 {/*4*/
119 "Non-ASCII multibyte control character U+180E",
120 "\xE1\xA0\x8E", NULL,
121 "nfs4_cis_prep",
122 U_STRINGPREP_PROHIBITED_ERROR
123 },
124 {/*5*/
125 "Non-ASCII control character U+1D175",
126 "\xF0\x9D\x85\xB5", NULL,
127 "nfs4_cis_prep",
128 U_STRINGPREP_PROHIBITED_ERROR
129 },
130 {/*6*/
131 "Plane 0 private use character U+F123",
132 "\xEF\x84\xA3", NULL,
133 "nfs4_cis_prep",
134 U_STRINGPREP_PROHIBITED_ERROR
135 },
136 {/*7*/
137 "Plane 15 private use character U+F1234",
138 "\xF3\xB1\x88\xB4", NULL,
139 "nfs4_cis_prep",
140 U_STRINGPREP_PROHIBITED_ERROR
141 },
142 {/*8*/
143 "Plane 16 private use character U+10F234",
144 "\xF4\x8F\x88\xB4", NULL,
145 "nfs4_cis_prep",
146 U_STRINGPREP_PROHIBITED_ERROR
147 },
148 {/*9*/
149 "Non-character code point U+8FFFE",
150 "\xF2\x8F\xBF\xBE", NULL,
151 "nfs4_cis_prep",
152 U_STRINGPREP_PROHIBITED_ERROR
153 },
154 {/*10*/
155 "Non-character code point U+10FFFF",
156 "\xF4\x8F\xBF\xBF", NULL,
157 "nfs4_cis_prep",
158 U_STRINGPREP_PROHIBITED_ERROR
159 },
160 /*
161 {
162 "Surrogate code U+DF42",
163 "\xED\xBD\x82", NULL, "nfs4_cis_prep", UIDNA_DEFAULT,
164 U_STRINGPREP_PROHIBITED_ERROR
165 },
166 */
167 {/*11*/
168 "Non-plain text character U+FFFD",
169 "\xEF\xBF\xBD", NULL,
170 "nfs4_cis_prep",
171 U_STRINGPREP_PROHIBITED_ERROR
172 },
173 {/*12*/
174 "Ideographic description character U+2FF5",
175 "\xE2\xBF\xB5", NULL,
176 "nfs4_cis_prep",
177 U_STRINGPREP_PROHIBITED_ERROR
178 },
179 {/*13*/
180 "Display property character U+0341",
181 "\xCD\x81", "\xCC\x81",
182 "nfs4_cis_prep", U_ZERO_ERROR
183
184 },
185
186 {/*14*/
187 "Left-to-right mark U+200E",
188 "\xE2\x80\x8E", "\xCC\x81",
189 "nfs4_cis_prep",
190 U_STRINGPREP_PROHIBITED_ERROR
191 },
192 {/*15*/
193
194 "Deprecated U+202A",
195 "\xE2\x80\xAA", "\xCC\x81",
196 "nfs4_cis_prep",
197 U_STRINGPREP_PROHIBITED_ERROR
198 },
199 {/*16*/
200 "Language tagging character U+E0001",
201 "\xF3\xA0\x80\x81", "\xCC\x81",
202 "nfs4_cis_prep",
203 U_STRINGPREP_PROHIBITED_ERROR
204 },
205 {/*17*/
206 "Language tagging character U+E0042",
207 "\xF3\xA0\x81\x82", NULL,
208 "nfs4_cis_prep",
209 U_STRINGPREP_PROHIBITED_ERROR
210 },
211 {/*18*/
212 "Bidi: RandALCat character U+05BE and LCat characters",
213 "\x66\x6F\x6F\xD6\xBE\x62\x61\x72", NULL,
214 "nfs4_cis_prep",
215 U_STRINGPREP_CHECK_BIDI_ERROR
216 },
217 {/*19*/
218 "Bidi: RandALCat character U+FD50 and LCat characters",
219 "\x66\x6F\x6F\xEF\xB5\x90\x62\x61\x72", NULL,
220 "nfs4_cis_prep",
221 U_STRINGPREP_CHECK_BIDI_ERROR
222 },
223 {/*20*/
224 "Bidi: RandALCat character U+FB38 and LCat characters",
225 "\x66\x6F\x6F\xEF\xB9\xB6\x62\x61\x72", "\x66\x6F\x6F\x20\xd9\x8e\x62\x61\x72",
226 "nfs4_cis_prep",
227 U_ZERO_ERROR
228 },
229 {/*21*/
230 "Bidi: RandALCat without trailing RandALCat U+0627 U+0031",
231 "\xD8\xA7\x31", NULL,
232 "nfs4_cis_prep",
233 U_STRINGPREP_CHECK_BIDI_ERROR
234 },
235 {/*22*/
236 "Bidi: RandALCat character U+0627 U+0031 U+0628",
237 "\xD8\xA7\x31\xD8\xA8", "\xD8\xA7\x31\xD8\xA8",
238 "nfs4_cis_prep",
239 U_ZERO_ERROR
240 },
241 {/*23*/
242 "Unassigned code point U+E0002",
243 "\xF3\xA0\x80\x82", NULL,
244 "nfs4_cis_prep",
245 U_STRINGPREP_UNASSIGNED_ERROR
246 },
247
248 /* // Invalid UTF-8
249 {
250 "Larger test (shrinking)",
251 "X\xC2\xAD\xC3\xDF\xC4\xB0\xE2\x84\xA1\x6a\xcc\x8c\xc2\xa0\xc2"
252 "\xaa\xce\xb0\xe2\x80\x80", "xssi\xcc\x87""tel\xc7\xb0 a\xce\xb0 ",
253 "nfs4_cis_prep",
254 U_ZERO_ERROR
255 },
256 {
257
258 "Larger test (expanding)",
259 "X\xC3\xDF\xe3\x8c\x96\xC4\xB0\xE2\x84\xA1\xE2\x92\x9F\xE3\x8c\x80",
260 "xss\xe3\x82\xad\xe3\x83\xad\xe3\x83\xa1\xe3\x83\xbc\xe3\x83\x88"
261 "\xe3\x83\xab""i\xcc\x87""tel\x28""d\x29\xe3\x82\xa2\xe3\x83\x91"
262 "\xe3\x83\xbc\xe3\x83\x88"
263 "nfs4_cis_prep",
264 U_ZERO_ERROR
265 },
266 */
267 };
268
269 #define MAX_BUFFER_SIZE 1000
270
271 static int32_t
272 unescapeData(const char* src, int32_t srcLen,
273 char* dest, int32_t destCapacity,
274 UErrorCode* status){
275
276 UChar b1Stack[MAX_BUFFER_SIZE];
277 int32_t b1Capacity = MAX_BUFFER_SIZE,
278 b1Len = 0,
279 destLen = 0;
280
281 UChar* b1 = b1Stack;
282
283 b1Len = u_unescape(src,b1,b1Capacity);
284
285 u_strToUTF8(dest, destCapacity, &destLen, b1, b1Len, status);
286
287 return destLen;
288 }
289
290
291 static void Test_nfs4_cis_prep(void){
292 int32_t i=0;
293
294 for(i=0;i< (int32_t)(sizeof(conformanceTestCases)/sizeof(conformanceTestCases[0]));i++){
295 const char* src = conformanceTestCases[i].in;
296 UErrorCode status = U_ZERO_ERROR;
297 UParseError parseError;
298 UErrorCode expectedStatus = conformanceTestCases[i].expectedStatus;
299 const char* expectedDest = conformanceTestCases[i].out;
300 char* dest = NULL;
301 int32_t destLen = 0;
302
303 destLen = nfs4_cis_prepare(src , (int32_t)strlen(src), dest, destLen, &parseError, &status);
304 if(status == U_BUFFER_OVERFLOW_ERROR){
305 status = U_ZERO_ERROR;
306 dest = (char*) malloc(++destLen);
307 destLen = nfs4_cis_prepare( src , (int32_t)strlen(src), dest, destLen, &parseError, &status);
308 }
309
310 if(expectedStatus != status){
311 log_err("Did not get the expected status for nfs4_cis_prep at index %i. Expected: %s Got: %s\n",i, u_errorName(expectedStatus), u_errorName(status));
312 }
313 if(U_SUCCESS(status) && (strcmp(expectedDest,dest) !=0)){
314 log_err("Did not get the expected output for nfs4_cis_prep at index %i.\n", i);
315 }
316 free(dest);
317 }
318 }
319
320
321
322 /*
323 There are several special identifiers ("who") which need to be
324 understood universally, rather than in the context of a particular
325 DNS domain. Some of these identifiers cannot be understood when an
326 NFS client accesses the server, but have meaning when a local process
327 accesses the file. The ability to display and modify these
328 permissions is permitted over NFS, even if none of the access methods
329 on the server understands the identifiers.
330
331 Who Description
332 _______________________________________________________________
333
334 "OWNER" The owner of the file.
335 "GROUP" The group associated with the file.
336 "EVERYONE" The world.
337 "INTERACTIVE" Accessed from an interactive terminal.
338 "NETWORK" Accessed via the network.
339 "DIALUP" Accessed as a dialup user to the server.
340 "BATCH" Accessed from a batch job.
341 "ANONYMOUS" Accessed without any authentication.
342 "AUTHENTICATED" Any authenticated user (opposite of
343 ANONYMOUS)
344 "SERVICE" Access from a system service.
345
346 To avoid conflict, these special identifiers are distinguish by an
347 appended "@" and should appear in the form "xxxx@" (note: no domain
348 name after the "@"). For example: ANONYMOUS@.
349 */
350 static const char* mixed_prep_data[] ={
351 "OWNER@",
352 "GROUP@",
353 "EVERYONE@",
354 "INTERACTIVE@",
355 "NETWORK@",
356 "DIALUP@",
357 "BATCH@",
358 "ANONYMOUS@",
359 "AUTHENTICATED@",
360 "\\u0930\\u094D\\u092E\\u094D\\u0915\\u094D\\u0937\\u0947\\u0924\\u094D@slip129-37-118-146.nc.us.ibm.net",
361 "\\u0936\\u094d\\u0930\\u0940\\u092e\\u0926\\u094d@saratoga.pe.utexas.edu",
362 "\\u092d\\u0917\\u0935\\u0926\\u094d\\u0917\\u0940\\u0924\\u093e@dial-120-45.ots.utexas.edu",
363 "\\u0905\\u0927\\u094d\\u092f\\u093e\\u092f@woo-085.dorms.waller.net",
364 "\\u0905\\u0930\\u094d\\u091c\\u0941\\u0928@hd30-049.hil.compuserve.com",
365 "\\u0935\\u093f\\u0937\\u093e\\u0926@pem203-31.pe.ttu.edu",
366 "\\u092f\\u094b\\u0917@56K-227.MaxTNT3.pdq.net",
367 "\\u0927\\u0943\\u0924\\u0930\\u093e\\u0937\\u094d\\u091f\\u094d\\u0930@dial-36-2.ots.utexas.edu",
368 "\\u0909\\u0935\\u093E\\u091A\\u0943@slip129-37-23-152.ga.us.ibm.net",
369 "\\u0927\\u0930\\u094d\\u092e\\u0915\\u094d\\u0937\\u0947\\u0924\\u094d\\u0930\\u0947@ts45ip119.cadvision.com",
370 "\\u0915\\u0941\\u0930\\u0941\\u0915\\u094d\\u0937\\u0947\\u0924\\u094d\\u0930\\u0947@sdn-ts-004txaustP05.dialsprint.net",
371 "\\u0938\\u092e\\u0935\\u0947\\u0924\\u093e@bar-tnt1s66.erols.com",
372 "\\u092f\\u0941\\u092f\\u0941\\u0924\\u094d\\u0938\\u0935\\u0903@101.st-louis-15.mo.dial-access.att.net",
373 "\\u092e\\u093e\\u092e\\u0915\\u093e\\u0903@h92-245.Arco.COM",
374 "\\u092a\\u093e\\u0923\\u094d\\u0921\\u0935\\u093e\\u0936\\u094d\\u091a\\u0948\\u0935@dial-13-2.ots.utexas.edu",
375 "\\u0915\\u093f\\u092e\\u0915\\u0941\\u0930\\u094d\\u0935\\u0924@net-redynet29.datamarkets.com.ar",
376 "\\u0938\\u0902\\u091c\\u0935@ccs-shiva28.reacciun.net.ve",
377 "\\u0c30\\u0c18\\u0c41\\u0c30\\u0c3e\\u0c2e\\u0c4d@7.houston-11.tx.dial-access.att.net",
378 "\\u0c35\\u0c3f\\u0c36\\u0c4d\\u0c35\\u0c28\\u0c3e\\u0c27@ingw129-37-120-26.mo.us.ibm.net",
379 "\\u0c06\\u0c28\\u0c02\\u0c26\\u0c4d@dialup6.austintx.com",
380 "\\u0C35\\u0C26\\u0C4D\\u0C26\\u0C3F\\u0C30\\u0C3E\\u0C1C\\u0C41@dns2.tpao.gov.tr",
381 "\\u0c30\\u0c3e\\u0c1c\\u0c40\\u0c35\\u0c4d@slip129-37-119-194.nc.us.ibm.net",
382 "\\u0c15\\u0c36\\u0c30\\u0c2c\\u0c3e\\u0c26@cs7.dillons.co.uk.203.119.193.in-addr.arpa",
383 "\\u0c38\\u0c02\\u0c1c\\u0c40\\u0c35\\u0c4d@swprd1.innovplace.saskatoon.sk.ca",
384 "\\u0c15\\u0c36\\u0c30\\u0c2c\\u0c3e\\u0c26@bikini.bologna.maraut.it",
385 "\\u0c38\\u0c02\\u0c1c\\u0c40\\u0c2c\\u0c4d@node91.subnet159-198-79.baxter.com",
386 "\\u0c38\\u0c46\\u0c28\\u0c4d\\u0c17\\u0c41\\u0c2a\\u0c4d\\u0c24@cust19.max5.new-york.ny.ms.uu.net",
387 "\\u0c05\\u0c2e\\u0c30\\u0c47\\u0c02\\u0c26\\u0c4d\\u0c30@balexander.slip.andrew.cmu.edu",
388 "\\u0c39\\u0c28\\u0c41\\u0c2e\\u0c3e\\u0c28\\u0c41\\u0c32@pool029.max2.denver.co.dynip.alter.net",
389 "\\u0c30\\u0c35\\u0c3f@cust49.max9.new-york.ny.ms.uu.net",
390 "\\u0c15\\u0c41\\u0c2e\\u0c3e\\u0c30\\u0c4d@s61.abq-dialin2.hollyberry.com",
391 "\\u0c35\\u0c3f\\u0c36\\u0c4d\\u0c35\\u0c28\\u0c3e\\u0c27@\\u0917\\u0928\\u0947\\u0936.sanjose.ibm.com",
392 "\\u0c06\\u0c26\\u0c3f\\u0c24\\u0c4d\\u0c2f@www.\\u00E0\\u00B3\\u00AF.com",
393 "\\u0C15\\u0C02\\u0C26\\u0C4D\\u0C30\\u0C47\\u0C17\\u0C41\\u0c32@www.\\u00C2\\u00A4.com",
394 "\\u0c36\\u0c4d\\u0c30\\u0c40\\u0C27\\u0C30\\u0C4D@www.\\u00C2\\u00A3.com",
395 "\\u0c15\\u0c02\\u0c1f\\u0c2e\\u0c36\\u0c46\\u0c1f\\u0c4d\\u0c1f\\u0c3f@\\u0025",
396 "\\u0c2e\\u0c3e\\u0c27\\u0c35\\u0c4d@\\u005C\\u005C",
397 "\\u0c26\\u0c46\\u0c36\\u0c46\\u0c1f\\u0c4d\\u0c1f\\u0c3f@www.\\u0021.com",
398 "test@www.\\u0024.com",
399 "help@\\u00C3\\u00BC.com",
400
401 };
402
403
404 static void
405 Test_nfs4_mixed_prep(void){
406 {
407 int32_t i=0;
408 char src[MAX_BUFFER_SIZE];
409 int32_t srcLen;
410
411 for(i=0; i< LENGTHOF(mixed_prep_data); i++){
412 int32_t destLen=0;
413 char* dest = NULL;
414 UErrorCode status = U_ZERO_ERROR;
415 UParseError parseError;
416 srcLen = unescapeData(mixed_prep_data[i], (int32_t)strlen(mixed_prep_data[i]), src, MAX_BUFFER_SIZE, &status);
417 if(U_FAILURE(status)){
418 log_err("Conversion of data at index %i failed. Error: %s\n", i, u_errorName(status));
419 continue;
420 }
421 destLen = nfs4_mixed_prepare(src, srcLen, NULL, 0, &parseError, &status);
422 if(status == U_BUFFER_OVERFLOW_ERROR){
423 status = U_ZERO_ERROR;
424 dest = (char*)malloc(++destLen);
425 destLen = nfs4_mixed_prepare(src, srcLen, dest, destLen, &parseError, &status);
426 }
427 free(dest);
428 if(U_FAILURE(status)){
429 log_err("Preparation of string at index %i failed. Error: %s\n", i, u_errorName(status));
430 continue;
431 }
432 }
433 }
434 /* test the error condition */
435 {
436 const char* source = "OWNER@oss.software.ibm.com";
437 char dest[MAX_BUFFER_SIZE];
438 char src[MAX_BUFFER_SIZE] = {0};
439 UErrorCode status = U_ZERO_ERROR;
440 UParseError parseError;
441
442 int32_t srcLen = unescapeData(source, (int32_t)strlen(source), src, MAX_BUFFER_SIZE, &status);
443
444 nfs4_mixed_prepare(src, srcLen, dest, MAX_BUFFER_SIZE, &parseError, &status);
445
446 if(status != U_PARSE_ERROR){
447 log_err("Did not get the expected error.Expected: %s Got: %s\n", u_errorName(U_PARSE_ERROR), u_errorName(status));
448 }
449 }
450
451
452 }
453
454 static void
455 Test_nfs4_cs_prep(void){
456 {
457 /* BiDi checking is turned off */
458 const char *source = "\\uC138\\uACC4\\uC758\\uBAA8\\uB4E0\\uC0AC\\uB78C\\uB4E4\\uC774\\u0644\\u064A\\u0647\\uD55C\\uAD6D\\uC5B4\\uB97C\\uC774\\uD574\\uD55C\\uB2E4\\uBA74";
459 UErrorCode status = U_ZERO_ERROR;
460 char src[MAX_BUFFER_SIZE]={'\0'};
461 UParseError parseError;
462 int32_t srcLen = unescapeData(source, (int32_t)strlen(source), src, MAX_BUFFER_SIZE, &status);
463 if(U_SUCCESS(status)){
464 char dest[MAX_BUFFER_SIZE] = {'\0'};
465 int32_t destLen = nfs4_cs_prepare(src, srcLen, dest, MAX_BUFFER_SIZE, FALSE, &parseError, &status);
466 if(U_FAILURE(status)){
467 log_err("StringPrep failed for case: BiDi Checking Turned OFF with error: %s\n", u_errorName(status));
468 }
469 if(strcmp(dest,src)!=0){
470 log_err("Did not get the expected output for case: BiDi Checking Turned OFF\n");
471 }
472 if(destLen != srcLen){
473 log_err("Did not get the expected length for the output for case: BiDi Checking Turned OFF. Expected: %i Got: %i\n", srcLen, destLen);
474 }
475 }else{
476 log_err("Conversion failed for case: BiDi Checking Turned OFF with error: %s\n", u_errorName(status));
477 }
478 }
479 {
480 /* Normalization turned off */
481 const char *source = "www.\\u00E0\\u00B3\\u00AF.com";
482 UErrorCode status = U_ZERO_ERROR;
483 char src[MAX_BUFFER_SIZE]={'\0'};
484 UParseError parseError;
485 int32_t srcLen = unescapeData(source, (int32_t)strlen(source), src, MAX_BUFFER_SIZE, &status);
486 if(U_SUCCESS(status)){
487 char dest[MAX_BUFFER_SIZE] = {'\0'};
488 int32_t destLen = nfs4_cs_prepare(src, srcLen, dest, MAX_BUFFER_SIZE, FALSE, &parseError, &status);
489 if(U_FAILURE(status)){
490 log_err("StringPrep failed for case: Normalization Turned OFF with error: %s\n", u_errorName(status));
491 }
492 if(strcmp(dest,src)!=0){
493 log_err("Did not get the expected output for case: Normalization Turned OFF\n");
494 }
495 if(destLen != srcLen){
496 log_err("Did not get the expected length for the output for case: Normalization Turned OFF. Expected: %i Got: %i\n", srcLen, destLen);
497 }
498 }else{
499 log_err("Conversion failed for case: Normalization Turned OFF with error: %s\n", u_errorName(status));
500 }
501 }
502 {
503 /* case mapping turned off */
504 const char *source = "THISISATEST";
505 UErrorCode status = U_ZERO_ERROR;
506 char src[MAX_BUFFER_SIZE]={'\0'};
507 UParseError parseError;
508 int32_t srcLen = unescapeData(source, (int32_t)strlen(source), src, MAX_BUFFER_SIZE, &status);
509 if(U_SUCCESS(status)){
510 char dest[MAX_BUFFER_SIZE] = {'\0'};
511 int32_t destLen = nfs4_cs_prepare(src, srcLen, dest, MAX_BUFFER_SIZE, TRUE, &parseError, &status);
512 if(U_FAILURE(status)){
513 log_err("StringPrep failed for case: Case Mapping Turned OFF with error: %s\n", u_errorName(status));
514 }
515 if(strcmp(dest,src)!=0){
516 log_err("Did not get the expected output for case: Case Mapping Turned OFF\n");
517 }
518 if(destLen != srcLen){
519 log_err("Did not get the expected length for the output for case: Case Mapping Turned OFF. Expected: %i Got: %i\n", srcLen, destLen);
520 }
521 }else{
522 log_err("Conversion failed for case: Case Mapping Turned OFF with error: %s\n", u_errorName(status));
523 }
524 }
525 {
526 /* case mapping turned on */
527 const char *source = "THISISATEST";
528 const char *expected = "thisisatest";
529 UErrorCode status = U_ZERO_ERROR;
530 char src[MAX_BUFFER_SIZE]={'\0'};
531 char exp[MAX_BUFFER_SIZE]={'\0'};
532 UParseError parseError;
533 int32_t srcLen = unescapeData(source, (int32_t)strlen(source), src, MAX_BUFFER_SIZE, &status);
534 int32_t expLen = unescapeData(expected, (int32_t)strlen(expected), exp, MAX_BUFFER_SIZE, &status);
535 if(U_SUCCESS(status)){
536 char dest[MAX_BUFFER_SIZE] = {'\0'};
537 int32_t destLen = nfs4_cs_prepare(src, srcLen, dest, MAX_BUFFER_SIZE, FALSE, &parseError, &status);
538 if(U_FAILURE(status)){
539 log_err("StringPrep failed for case: Case Mapping Turned On with error: %s\n", u_errorName(status));
540 }
541 if(strcmp(exp, dest)!=0){
542 log_err("Did not get the expected output for case: Case Mapping Turned On!\n");
543 }
544 if(destLen != expLen){
545 log_err("Did not get the expected length for the outputfor case: Case Mapping Turned On. Expected: %i Got: %i\n", strlen(expected), destLen);
546 }
547 }else{
548 log_err("Conversion failed for case: Case Mapping Turned ON with error: %s\n", u_errorName(status));
549 }
550 }
551 }
552
553 #endif
554
555 /*
556 * Hey, Emacs, please set the following:
557 *
558 * Local Variables:
559 * indent-tabs-mode: nil
560 * End:
561 *
562 */