Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: source/test/intltest/uts46test.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/test/intltest/ustrtest.cpp ('k') | source/test/intltest/utxttest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************* 2 *******************************************************************************
3 * Copyright (C) 2010-2011, International Business Machines 3 * Copyright (C) 2010-2014, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************* 5 *******************************************************************************
6 * file name: uts46test.cpp 6 * file name: uts46test.cpp
7 * encoding: US-ASCII 7 * encoding: US-ASCII
8 * tab size: 8 (not used) 8 * tab size: 8 (not used)
9 * indentation:4 9 * indentation:4
10 * 10 *
11 * created on: 2010may05 11 * created on: 2010may05
12 * created by: Markus W. Scherer 12 * created by: Markus W. Scherer
13 */ 13 */
14 14
15 #include "unicode/utypes.h" 15 #include "unicode/utypes.h"
16 16
17 #if !UCONFIG_NO_IDNA 17 #if !UCONFIG_NO_IDNA
18 18
19 #include <string.h> 19 #include <string.h>
20 #include "unicode/bytestream.h" 20 #include "unicode/bytestream.h"
21 #include "unicode/idna.h" 21 #include "unicode/idna.h"
22 #include "unicode/localpointer.h" 22 #include "unicode/localpointer.h"
23 #include "unicode/std_string.h" 23 #include "unicode/std_string.h"
24 #include "unicode/stringpiece.h" 24 #include "unicode/stringpiece.h"
25 #include "unicode/uidna.h" 25 #include "unicode/uidna.h"
26 #include "unicode/unistr.h" 26 #include "unicode/unistr.h"
27 #include "intltest.h" 27 #include "intltest.h"
28 28 #include "cmemory.h"
29 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
30 29
31 class UTS46Test : public IntlTest { 30 class UTS46Test : public IntlTest {
32 public: 31 public:
33 UTS46Test() : trans(NULL), nontrans(NULL) {} 32 UTS46Test() : trans(NULL), nontrans(NULL) {}
34 virtual ~UTS46Test(); 33 virtual ~UTS46Test();
35 34
36 void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par= NULL); 35 void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par= NULL);
37 void TestAPI(); 36 void TestAPI();
38 void TestNotSTD3(); 37 void TestNotSTD3();
39 void TestSomeCases(); 38 void TestSomeCases();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 nontrans->labelToASCII(input, result, info, errorCode); 139 nontrans->labelToASCII(input, result, info, errorCode);
141 if( U_FAILURE(errorCode) || 140 if( U_FAILURE(errorCode) ||
142 info.getErrors()!=(UIDNA_ERROR_LABEL_HAS_DOT|UIDNA_ERROR_INVALID_ACE_LAB EL) || 141 info.getErrors()!=(UIDNA_ERROR_LABEL_HAS_DOT|UIDNA_ERROR_INVALID_ACE_LAB EL) ||
143 result!=expected 142 result!=expected
144 ) { 143 ) {
145 errln("N.labelToASCII(label-with-dot) failed with errors %04lx - %s", 144 errln("N.labelToASCII(label-with-dot) failed with errors %04lx - %s",
146 info.getErrors(), u_errorName(errorCode)); 145 info.getErrors(), u_errorName(errorCode));
147 } 146 }
148 // UTF-8 147 // UTF-8
149 char buffer[100]; 148 char buffer[100];
150 TestCheckedArrayByteSink sink(buffer, LENGTHOF(buffer)); 149 TestCheckedArrayByteSink sink(buffer, UPRV_LENGTHOF(buffer));
151 errorCode=U_ZERO_ERROR; 150 errorCode=U_ZERO_ERROR;
152 nontrans->labelToUnicodeUTF8(StringPiece(NULL, 5), sink, info, errorCode); 151 nontrans->labelToUnicodeUTF8(StringPiece(NULL, 5), sink, info, errorCode);
153 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || sink.NumberOfBytesWritten()!=0) { 152 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || sink.NumberOfBytesWritten()!=0) {
154 errln("N.labelToUnicodeUTF8(StringPiece(NULL, 5)) did not set illegal-ar gument-error ", 153 errln("N.labelToUnicodeUTF8(StringPiece(NULL, 5)) did not set illegal-ar gument-error ",
155 "or did output something - %s", 154 "or did output something - %s",
156 u_errorName(errorCode)); 155 u_errorName(errorCode));
157 } 156 }
158 157
159 sink.Reset(); 158 sink.Reset();
160 errorCode=U_ZERO_ERROR; 159 errorCode=U_ZERO_ERROR;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 if(errorCode.isFailure()) { 206 if(errorCode.isFailure()) {
208 return; 207 return;
209 } 208 }
210 UnicodeString input=UNICODE_STRING_SIMPLE("\\u0000A_2+2=4\\u000A.e\\u00DFen. net").unescape(); 209 UnicodeString input=UNICODE_STRING_SIMPLE("\\u0000A_2+2=4\\u000A.e\\u00DFen. net").unescape();
211 UnicodeString result; 210 UnicodeString result;
212 IDNAInfo info; 211 IDNAInfo info;
213 if( not3->nameToUnicode(input, result, info, errorCode)!= 212 if( not3->nameToUnicode(input, result, info, errorCode)!=
214 UNICODE_STRING_SIMPLE("\\u0000a_2+2=4\\u000A.essen.net").unescape() || 213 UNICODE_STRING_SIMPLE("\\u0000a_2+2=4\\u000A.essen.net").unescape() ||
215 info.hasErrors() 214 info.hasErrors()
216 ) { 215 ) {
217 prettify(result).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 216 prettify(result).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
218 errln("notSTD3.nameToUnicode(non-LDH ASCII) unexpected errors %04lx stri ng %s", 217 errln("notSTD3.nameToUnicode(non-LDH ASCII) unexpected errors %04lx stri ng %s",
219 (long)info.getErrors(), buffer); 218 (long)info.getErrors(), buffer);
220 } 219 }
221 // A space (BiDi class WS) is not allowed in a BiDi domain name. 220 // A space (BiDi class WS) is not allowed in a BiDi domain name.
222 input=UNICODE_STRING_SIMPLE("a z.xn--4db.edu"); 221 input=UNICODE_STRING_SIMPLE("a z.xn--4db.edu");
223 not3->nameToASCII(input, result, info, errorCode); 222 not3->nameToASCII(input, result, info, errorCode);
224 if(result!=input || info.getErrors()!=UIDNA_ERROR_BIDI) { 223 if(result!=input || info.getErrors()!=UIDNA_ERROR_BIDI) {
225 errln("notSTD3.nameToASCII(ASCII-with-space.alef.edu) failed"); 224 errln("notSTD3.nameToASCII(ASCII-with-space.alef.edu) failed");
226 } 225 }
227 // Characters that are canonically equivalent to sequences with non-LDH ASCI I. 226 // Characters that are canonically equivalent to sequences with non-LDH ASCI I.
228 input=UNICODE_STRING_SIMPLE("a\\u2260b\\u226Ec\\u226Fd").unescape(); 227 input=UNICODE_STRING_SIMPLE("a\\u2260b\\u226Ec\\u226Fd").unescape();
229 not3->nameToUnicode(input, result, info, errorCode); 228 not3->nameToUnicode(input, result, info, errorCode);
230 if(result!=input || info.hasErrors()) { 229 if(result!=input || info.hasErrors()) {
231 prettify(result).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 230 prettify(result).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
232 errln("notSTD3.nameToUnicode(equiv to non-LDH ASCII) unexpected errors % 04lx string %s", 231 errln("notSTD3.nameToUnicode(equiv to non-LDH ASCII) unexpected errors % 04lx string %s",
233 (long)info.getErrors(), buffer); 232 (long)info.getErrors(), buffer);
234 } 233 }
235 } 234 }
236 235
237 struct TestCase { 236 struct TestCase {
238 // Input string and options string (Nontransitional/Transitional/Both). 237 // Input string and options string (Nontransitional/Transitional/Both).
239 const char *s, *o; 238 const char *s, *o;
240 // Expected Unicode result string. 239 // Expected Unicode result string.
241 const char *u; 240 const char *u;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 { "123456789012345678901234567890123456789012345678901234567890123." 458 { "123456789012345678901234567890123456789012345678901234567890123."
460 "1234567890\\u00E41234567890123456789012345678901234567890123456." 459 "1234567890\\u00E41234567890123456789012345678901234567890123456."
461 "123456789012345678901234567890123456789012345678901234567890123." 460 "123456789012345678901234567890123456789012345678901234567890123."
462 "1234567890123456789012345678901234567890123456789012345678901", "B", 461 "1234567890123456789012345678901234567890123456789012345678901", "B",
463 "123456789012345678901234567890123456789012345678901234567890123." 462 "123456789012345678901234567890123456789012345678901234567890123."
464 "1234567890\\u00E41234567890123456789012345678901234567890123456." 463 "1234567890\\u00E41234567890123456789012345678901234567890123456."
465 "123456789012345678901234567890123456789012345678901234567890123." 464 "123456789012345678901234567890123456789012345678901234567890123."
466 "1234567890123456789012345678901234567890123456789012345678901", 465 "1234567890123456789012345678901234567890123456789012345678901",
467 UIDNA_ERROR_LABEL_TOO_LONG|UIDNA_ERROR_DOMAIN_NAME_TOO_LONG }, 466 UIDNA_ERROR_LABEL_TOO_LONG|UIDNA_ERROR_DOMAIN_NAME_TOO_LONG },
468 // hyphen errors and empty-label errors 467 // hyphen errors and empty-label errors
468 // Ticket #10883: ToUnicode also checks for empty labels.
469 { ".", "B", ".", UIDNA_ERROR_EMPTY_LABEL },
470 { "\\uFF0E", "B", ".", UIDNA_ERROR_EMPTY_LABEL },
469 // "xn---q----jra"=="-q--a-umlaut-" 471 // "xn---q----jra"=="-q--a-umlaut-"
470 { "a.b..-q--a-.e", "B", "a.b..-q--a-.e", 472 { "a.b..-q--a-.e", "B", "a.b..-q--a-.e",
471 UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HY PHEN| 473 UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HY PHEN|
472 UIDNA_ERROR_HYPHEN_3_4 }, 474 UIDNA_ERROR_HYPHEN_3_4 },
473 { "a.b..-q--\\u00E4-.e", "B", "a.b..-q--\\u00E4-.e", 475 { "a.b..-q--\\u00E4-.e", "B", "a.b..-q--\\u00E4-.e",
474 UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HY PHEN| 476 UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HY PHEN|
475 UIDNA_ERROR_HYPHEN_3_4 }, 477 UIDNA_ERROR_HYPHEN_3_4 },
476 { "a.b..xn---q----jra.e", "B", "a.b..-q--\\u00E4-.e", 478 { "a.b..xn---q----jra.e", "B", "a.b..-q--\\u00E4-.e",
477 UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HY PHEN| 479 UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HY PHEN|
478 UIDNA_ERROR_HYPHEN_3_4 }, 480 UIDNA_ERROR_HYPHEN_3_4 },
479 { "a..c", "B", "a..c", UIDNA_ERROR_EMPTY_LABEL }, 481 { "a..c", "B", "a..c", UIDNA_ERROR_EMPTY_LABEL },
482 { "a.xn--.c", "B", "a..c", UIDNA_ERROR_EMPTY_LABEL },
480 { "a.-b.", "B", "a.-b.", UIDNA_ERROR_LEADING_HYPHEN }, 483 { "a.-b.", "B", "a.-b.", UIDNA_ERROR_LEADING_HYPHEN },
481 { "a.b-.c", "B", "a.b-.c", UIDNA_ERROR_TRAILING_HYPHEN }, 484 { "a.b-.c", "B", "a.b-.c", UIDNA_ERROR_TRAILING_HYPHEN },
482 { "a.-.c", "B", "a.-.c", UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYP HEN }, 485 { "a.-.c", "B", "a.-.c", UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYP HEN },
483 { "a.bc--de.f", "B", "a.bc--de.f", UIDNA_ERROR_HYPHEN_3_4 }, 486 { "a.bc--de.f", "B", "a.bc--de.f", UIDNA_ERROR_HYPHEN_3_4 },
484 { "\\u00E4.\\u00AD.c", "B", "\\u00E4..c", UIDNA_ERROR_EMPTY_LABEL }, 487 { "\\u00E4.\\u00AD.c", "B", "\\u00E4..c", UIDNA_ERROR_EMPTY_LABEL },
488 { "\\u00E4.xn--.c", "B", "\\u00E4..c", UIDNA_ERROR_EMPTY_LABEL },
485 { "\\u00E4.-b.", "B", "\\u00E4.-b.", UIDNA_ERROR_LEADING_HYPHEN }, 489 { "\\u00E4.-b.", "B", "\\u00E4.-b.", UIDNA_ERROR_LEADING_HYPHEN },
486 { "\\u00E4.b-.c", "B", "\\u00E4.b-.c", UIDNA_ERROR_TRAILING_HYPHEN }, 490 { "\\u00E4.b-.c", "B", "\\u00E4.b-.c", UIDNA_ERROR_TRAILING_HYPHEN },
487 { "\\u00E4.-.c", "B", "\\u00E4.-.c", UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_ TRAILING_HYPHEN }, 491 { "\\u00E4.-.c", "B", "\\u00E4.-.c", UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_ TRAILING_HYPHEN },
488 { "\\u00E4.bc--de.f", "B", "\\u00E4.bc--de.f", UIDNA_ERROR_HYPHEN_3_4 }, 492 { "\\u00E4.bc--de.f", "B", "\\u00E4.bc--de.f", UIDNA_ERROR_HYPHEN_3_4 },
489 { "a.b.\\u0308c.d", "B", "a.b.\\uFFFDc.d", UIDNA_ERROR_LEADING_COMBINING_MAR K }, 493 { "a.b.\\u0308c.d", "B", "a.b.\\uFFFDc.d", UIDNA_ERROR_LEADING_COMBINING_MAR K },
490 { "a.b.xn--c-bcb.d", "B", 494 { "a.b.xn--c-bcb.d", "B",
491 "a.b.xn--c-bcb\\uFFFD.d", UIDNA_ERROR_LEADING_COMBINING_MARK|UIDNA_ERROR_I NVALID_ACE_LABEL }, 495 "a.b.xn--c-bcb\\uFFFD.d", UIDNA_ERROR_LEADING_COMBINING_MARK|UIDNA_ERROR_I NVALID_ACE_LABEL },
492 // BiDi 496 // BiDi
493 { "A0", "B", "a0", 0 }, 497 { "A0", "B", "a0", 0 },
494 { "0A", "B", "0a", 0 }, // all-LTR is ok to start with a digit (EN) 498 { "0A", "B", "0a", 0 }, // all-LTR is ok to start with a digit (EN)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 { "xn--aaaaaaaaaaaa-nlb.de", "B", "aaaaaaaaaaa\\u00FCa.de", 0 }, 578 { "xn--aaaaaaaaaaaa-nlb.de", "B", "aaaaaaaaaaa\\u00FCa.de", 0 },
575 { "xn--schluprfung-z6a39a.de", "B", "schlu\\u00DFpr\\u00FCfung.de", 0 }, 579 { "xn--schluprfung-z6a39a.de", "B", "schlu\\u00DFpr\\u00FCfung.de", 0 },
576 // { "", "B", 580 // { "", "B",
577 // "", 0 }, 581 // "", 0 },
578 }; 582 };
579 583
580 void UTS46Test::TestSomeCases() { 584 void UTS46Test::TestSomeCases() {
581 IcuTestErrorCode errorCode(*this, "TestSomeCases"); 585 IcuTestErrorCode errorCode(*this, "TestSomeCases");
582 char buffer[400], buffer2[400]; 586 char buffer[400], buffer2[400];
583 int32_t i; 587 int32_t i;
584 for(i=0; i<LENGTHOF(testCases); ++i) { 588 for(i=0; i<UPRV_LENGTHOF(testCases); ++i) {
585 const TestCase &testCase=testCases[i]; 589 const TestCase &testCase=testCases[i];
586 UnicodeString input(ctou(testCase.s)); 590 UnicodeString input(ctou(testCase.s));
587 UnicodeString expected(ctou(testCase.u)); 591 UnicodeString expected(ctou(testCase.u));
588 // ToASCII/ToUnicode, transitional/nontransitional 592 // ToASCII/ToUnicode, transitional/nontransitional
589 UnicodeString aT, uT, aN, uN; 593 UnicodeString aT, uT, aN, uN;
590 IDNAInfo aTInfo, uTInfo, aNInfo, uNInfo; 594 IDNAInfo aTInfo, uTInfo, aNInfo, uNInfo;
591 trans->nameToASCII(input, aT, aTInfo, errorCode); 595 trans->nameToASCII(input, aT, aTInfo, errorCode);
592 trans->nameToUnicode(input, uT, uTInfo, errorCode); 596 trans->nameToUnicode(input, uT, uTInfo, errorCode);
593 nontrans->nameToASCII(input, aN, aNInfo, errorCode); 597 nontrans->nameToASCII(input, aN, aNInfo, errorCode);
594 nontrans->nameToUnicode(input, uN, uNInfo, errorCode); 598 nontrans->nameToUnicode(input, uN, uNInfo, errorCode);
595 if(errorCode.logIfFailureAndReset("first-level processing [%d/%s] %s", 599 if(errorCode.logIfFailureAndReset("first-level processing [%d/%s] %s",
596 (int)i, testCase.o, testCase.s) 600 (int)i, testCase.o, testCase.s)
597 ) { 601 ) {
598 continue; 602 continue;
599 } 603 }
600 // ToUnicode does not set length errors. 604 // ToUnicode does not set length-overflow errors.
601 uint32_t uniErrors=testCase.errors&~ 605 uint32_t uniErrors=testCase.errors&~
602 (UIDNA_ERROR_EMPTY_LABEL| 606 (UIDNA_ERROR_LABEL_TOO_LONG|
603 UIDNA_ERROR_LABEL_TOO_LONG|
604 UIDNA_ERROR_DOMAIN_NAME_TOO_LONG); 607 UIDNA_ERROR_DOMAIN_NAME_TOO_LONG);
605 char mode=testCase.o[0]; 608 char mode=testCase.o[0];
606 if(mode=='B' || mode=='N') { 609 if(mode=='B' || mode=='N') {
607 if(uNInfo.getErrors()!=uniErrors) { 610 if(uNInfo.getErrors()!=uniErrors) {
608 errln("N.nameToUnicode([%d] %s) unexpected errors %04lx", 611 errln("N.nameToUnicode([%d] %s) unexpected errors %04lx",
609 (int)i, testCase.s, (long)uNInfo.getErrors()); 612 (int)i, testCase.s, (long)uNInfo.getErrors());
610 continue; 613 continue;
611 } 614 }
612 if(uN!=expected) { 615 if(uN!=expected) {
613 prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 616 prettify(uN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer ));
614 errln("N.nameToUnicode([%d] %s) unexpected string %s", 617 errln("N.nameToUnicode([%d] %s) unexpected string %s",
615 (int)i, testCase.s, buffer); 618 (int)i, testCase.s, buffer);
616 continue; 619 continue;
617 } 620 }
618 if(aNInfo.getErrors()!=testCase.errors) { 621 if(aNInfo.getErrors()!=testCase.errors) {
619 errln("N.nameToASCII([%d] %s) unexpected errors %04lx", 622 errln("N.nameToASCII([%d] %s) unexpected errors %04lx",
620 (int)i, testCase.s, (long)aNInfo.getErrors()); 623 (int)i, testCase.s, (long)aNInfo.getErrors());
621 continue; 624 continue;
622 } 625 }
623 } 626 }
624 if(mode=='B' || mode=='T') { 627 if(mode=='B' || mode=='T') {
625 if(uTInfo.getErrors()!=uniErrors) { 628 if(uTInfo.getErrors()!=uniErrors) {
626 errln("T.nameToUnicode([%d] %s) unexpected errors %04lx", 629 errln("T.nameToUnicode([%d] %s) unexpected errors %04lx",
627 (int)i, testCase.s, (long)uTInfo.getErrors()); 630 (int)i, testCase.s, (long)uTInfo.getErrors());
628 continue; 631 continue;
629 } 632 }
630 if(uT!=expected) { 633 if(uT!=expected) {
631 prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 634 prettify(uT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer ));
632 errln("T.nameToUnicode([%d] %s) unexpected string %s", 635 errln("T.nameToUnicode([%d] %s) unexpected string %s",
633 (int)i, testCase.s, buffer); 636 (int)i, testCase.s, buffer);
634 continue; 637 continue;
635 } 638 }
636 if(aTInfo.getErrors()!=testCase.errors) { 639 if(aTInfo.getErrors()!=testCase.errors) {
637 errln("T.nameToASCII([%d] %s) unexpected errors %04lx", 640 errln("T.nameToASCII([%d] %s) unexpected errors %04lx",
638 (int)i, testCase.s, (long)aTInfo.getErrors()); 641 (int)i, testCase.s, (long)aTInfo.getErrors());
639 continue; 642 continue;
640 } 643 }
641 } 644 }
642 // ToASCII is all-ASCII if no severe errors 645 // ToASCII is all-ASCII if no severe errors
643 if((aNInfo.getErrors()&severeErrors)==0 && !isASCII(aN)) { 646 if((aNInfo.getErrors()&severeErrors)==0 && !isASCII(aN)) {
644 prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 647 prettify(aN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
645 errln("N.nameToASCII([%d] %s) (errors %04lx) result is not ASCII %s" , 648 errln("N.nameToASCII([%d] %s) (errors %04lx) result is not ASCII %s" ,
646 (int)i, testCase.s, aNInfo.getErrors(), buffer); 649 (int)i, testCase.s, aNInfo.getErrors(), buffer);
647 continue; 650 continue;
648 } 651 }
649 if((aTInfo.getErrors()&severeErrors)==0 && !isASCII(aT)) { 652 if((aTInfo.getErrors()&severeErrors)==0 && !isASCII(aT)) {
650 prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 653 prettify(aT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
651 errln("T.nameToASCII([%d] %s) (errors %04lx) result is not ASCII %s" , 654 errln("T.nameToASCII([%d] %s) (errors %04lx) result is not ASCII %s" ,
652 (int)i, testCase.s, aTInfo.getErrors(), buffer); 655 (int)i, testCase.s, aTInfo.getErrors(), buffer);
653 continue; 656 continue;
654 } 657 }
655 if(verbose) { 658 if(verbose) {
656 char m= mode=='B' ? mode : 'N'; 659 char m= mode=='B' ? mode : 'N';
657 prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 660 prettify(aN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
658 logln("%c.nameToASCII([%d] %s) (errors %04lx) result string: %s", 661 logln("%c.nameToASCII([%d] %s) (errors %04lx) result string: %s",
659 m, (int)i, testCase.s, aNInfo.getErrors(), buffer); 662 m, (int)i, testCase.s, aNInfo.getErrors(), buffer);
660 if(mode!='B') { 663 if(mode!='B') {
661 prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 664 prettify(aT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer ));
662 logln("T.nameToASCII([%d] %s) (errors %04lx) result string: %s", 665 logln("T.nameToASCII([%d] %s) (errors %04lx) result string: %s",
663 (int)i, testCase.s, aTInfo.getErrors(), buffer); 666 (int)i, testCase.s, aTInfo.getErrors(), buffer);
664 } 667 }
665 } 668 }
666 // second-level processing 669 // second-level processing
667 UnicodeString aTuN, uTaN, aNuN, uNaN; 670 UnicodeString aTuN, uTaN, aNuN, uNaN;
668 IDNAInfo aTuNInfo, uTaNInfo, aNuNInfo, uNaNInfo; 671 IDNAInfo aTuNInfo, uTaNInfo, aNuNInfo, uNaNInfo;
669 nontrans->nameToUnicode(aT, aTuN, aTuNInfo, errorCode); 672 nontrans->nameToUnicode(aT, aTuN, aTuNInfo, errorCode);
670 nontrans->nameToASCII(uT, uTaN, uTaNInfo, errorCode); 673 nontrans->nameToASCII(uT, uTaN, uTaNInfo, errorCode);
671 nontrans->nameToUnicode(aN, aNuN, aNuNInfo, errorCode); 674 nontrans->nameToUnicode(aN, aNuN, aNuNInfo, errorCode);
672 nontrans->nameToASCII(uN, uNaN, uNaNInfo, errorCode); 675 nontrans->nameToASCII(uN, uNaN, uNaNInfo, errorCode);
673 if(errorCode.logIfFailureAndReset("second-level processing [%d/%s] %s", 676 if(errorCode.logIfFailureAndReset("second-level processing [%d/%s] %s",
674 (int)i, testCase.o, testCase.s) 677 (int)i, testCase.o, testCase.s)
675 ) { 678 ) {
676 continue; 679 continue;
677 } 680 }
678 if(aN!=uNaN) { 681 if(aN!=uNaN) {
679 prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 682 prettify(aN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
680 prettify(uNaN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2)); 683 prettify(uNaN).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buffer2 ));
681 errln("N.nameToASCII([%d] %s)!=N.nameToUnicode().N.nameToASCII() " 684 errln("N.nameToASCII([%d] %s)!=N.nameToUnicode().N.nameToASCII() "
682 "(errors %04lx) %s vs. %s", 685 "(errors %04lx) %s vs. %s",
683 (int)i, testCase.s, aNInfo.getErrors(), buffer, buffer2); 686 (int)i, testCase.s, aNInfo.getErrors(), buffer, buffer2);
684 continue; 687 continue;
685 } 688 }
686 if(aT!=uTaN) { 689 if(aT!=uTaN) {
687 prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 690 prettify(aT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
688 prettify(uTaN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2)); 691 prettify(uTaN).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buffer2 ));
689 errln("T.nameToASCII([%d] %s)!=T.nameToUnicode().N.nameToASCII() " 692 errln("T.nameToASCII([%d] %s)!=T.nameToUnicode().N.nameToASCII() "
690 "(errors %04lx) %s vs. %s", 693 "(errors %04lx) %s vs. %s",
691 (int)i, testCase.s, aNInfo.getErrors(), buffer, buffer2); 694 (int)i, testCase.s, aNInfo.getErrors(), buffer, buffer2);
692 continue; 695 continue;
693 } 696 }
694 if(uN!=aNuN) { 697 if(uN!=aNuN) {
695 prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 698 prettify(uN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
696 prettify(aNuN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2)); 699 prettify(aNuN).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buffer2 ));
697 errln("N.nameToUnicode([%d] %s)!=N.nameToASCII().N.nameToUnicode() " 700 errln("N.nameToUnicode([%d] %s)!=N.nameToASCII().N.nameToUnicode() "
698 "(errors %04lx) %s vs. %s", 701 "(errors %04lx) %s vs. %s",
699 (int)i, testCase.s, uNInfo.getErrors(), buffer, buffer2); 702 (int)i, testCase.s, uNInfo.getErrors(), buffer, buffer2);
700 continue; 703 continue;
701 } 704 }
702 if(uT!=aTuN) { 705 if(uT!=aTuN) {
703 prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 706 prettify(uT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer));
704 prettify(aTuN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2)); 707 prettify(aTuN).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buffer2 ));
705 errln("T.nameToUnicode([%d] %s)!=T.nameToASCII().N.nameToUnicode() " 708 errln("T.nameToUnicode([%d] %s)!=T.nameToASCII().N.nameToUnicode() "
706 "(errors %04lx) %s vs. %s", 709 "(errors %04lx) %s vs. %s",
707 (int)i, testCase.s, uNInfo.getErrors(), buffer, buffer2); 710 (int)i, testCase.s, uNInfo.getErrors(), buffer, buffer2);
708 continue; 711 continue;
709 } 712 }
710 // labelToUnicode 713 // labelToUnicode
711 UnicodeString aTL, uTL, aNL, uNL; 714 UnicodeString aTL, uTL, aNL, uNL;
712 IDNAInfo aTLInfo, uTLInfo, aNLInfo, uNLInfo; 715 IDNAInfo aTLInfo, uTLInfo, aNLInfo, uNLInfo;
713 trans->labelToASCII(input, aTL, aTLInfo, errorCode); 716 trans->labelToASCII(input, aTL, aTLInfo, errorCode);
714 trans->labelToUnicode(input, uTL, uTLInfo, errorCode); 717 trans->labelToUnicode(input, uTL, uTLInfo, errorCode);
715 nontrans->labelToASCII(input, aNL, aNLInfo, errorCode); 718 nontrans->labelToASCII(input, aNL, aNLInfo, errorCode);
716 nontrans->labelToUnicode(input, uNL, uNLInfo, errorCode); 719 nontrans->labelToUnicode(input, uNL, uNLInfo, errorCode);
717 if(errorCode.logIfFailureAndReset("labelToXYZ processing [%d/%s] %s", 720 if(errorCode.logIfFailureAndReset("labelToXYZ processing [%d/%s] %s",
718 (int)i, testCase.o, testCase.s) 721 (int)i, testCase.o, testCase.s)
719 ) { 722 ) {
720 continue; 723 continue;
721 } 724 }
722 if(aN.indexOf((UChar)0x2e)<0) { 725 if(aN.indexOf((UChar)0x2e)<0) {
723 if(aN!=aNL || aNInfo.getErrors()!=aNLInfo.getErrors()) { 726 if(aN!=aNL || aNInfo.getErrors()!=aNLInfo.getErrors()) {
724 prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 727 prettify(aN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer ));
725 prettify(aNL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2)) ; 728 prettify(aNL).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buff er2));
726 errln("N.nameToASCII([%d] %s)!=N.labelToASCII() " 729 errln("N.nameToASCII([%d] %s)!=N.labelToASCII() "
727 "(errors %04lx vs %04lx) %s vs. %s", 730 "(errors %04lx vs %04lx) %s vs. %s",
728 (int)i, testCase.s, aNInfo.getErrors(), aNLInfo.getErrors( ), buffer, buffer2); 731 (int)i, testCase.s, aNInfo.getErrors(), aNLInfo.getErrors( ), buffer, buffer2);
729 continue; 732 continue;
730 } 733 }
731 } else { 734 } else {
732 if((aNLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) { 735 if((aNLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) {
733 errln("N.labelToASCII([%d] %s) errors %04lx missing UIDNA_ERROR_ LABEL_HAS_DOT", 736 errln("N.labelToASCII([%d] %s) errors %04lx missing UIDNA_ERROR_ LABEL_HAS_DOT",
734 (int)i, testCase.s, (long)aNLInfo.getErrors()); 737 (int)i, testCase.s, (long)aNLInfo.getErrors());
735 continue; 738 continue;
736 } 739 }
737 } 740 }
738 if(aT.indexOf((UChar)0x2e)<0) { 741 if(aT.indexOf((UChar)0x2e)<0) {
739 if(aT!=aTL || aTInfo.getErrors()!=aTLInfo.getErrors()) { 742 if(aT!=aTL || aTInfo.getErrors()!=aTLInfo.getErrors()) {
740 prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 743 prettify(aT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer ));
741 prettify(aTL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2)) ; 744 prettify(aTL).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buff er2));
742 errln("T.nameToASCII([%d] %s)!=T.labelToASCII() " 745 errln("T.nameToASCII([%d] %s)!=T.labelToASCII() "
743 "(errors %04lx vs %04lx) %s vs. %s", 746 "(errors %04lx vs %04lx) %s vs. %s",
744 (int)i, testCase.s, aTInfo.getErrors(), aTLInfo.getErrors( ), buffer, buffer2); 747 (int)i, testCase.s, aTInfo.getErrors(), aTLInfo.getErrors( ), buffer, buffer2);
745 continue; 748 continue;
746 } 749 }
747 } else { 750 } else {
748 if((aTLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) { 751 if((aTLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) {
749 errln("T.labelToASCII([%d] %s) errors %04lx missing UIDNA_ERROR_ LABEL_HAS_DOT", 752 errln("T.labelToASCII([%d] %s) errors %04lx missing UIDNA_ERROR_ LABEL_HAS_DOT",
750 (int)i, testCase.s, (long)aTLInfo.getErrors()); 753 (int)i, testCase.s, (long)aTLInfo.getErrors());
751 continue; 754 continue;
752 } 755 }
753 } 756 }
754 if(uN.indexOf((UChar)0x2e)<0) { 757 if(uN.indexOf((UChar)0x2e)<0) {
755 if(uN!=uNL || uNInfo.getErrors()!=uNLInfo.getErrors()) { 758 if(uN!=uNL || uNInfo.getErrors()!=uNLInfo.getErrors()) {
756 prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 759 prettify(uN).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer ));
757 prettify(uNL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2)) ; 760 prettify(uNL).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buff er2));
758 errln("N.nameToUnicode([%d] %s)!=N.labelToUnicode() " 761 errln("N.nameToUnicode([%d] %s)!=N.labelToUnicode() "
759 "(errors %04lx vs %04lx) %s vs. %s", 762 "(errors %04lx vs %04lx) %s vs. %s",
760 (int)i, testCase.s, uNInfo.getErrors(), uNLInfo.getErrors( ), buffer, buffer2); 763 (int)i, testCase.s, uNInfo.getErrors(), uNLInfo.getErrors( ), buffer, buffer2);
761 continue; 764 continue;
762 } 765 }
763 } else { 766 } else {
764 if((uNLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) { 767 if((uNLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) {
765 errln("N.labelToUnicode([%d] %s) errors %04lx missing UIDNA_ERRO R_LABEL_HAS_DOT", 768 errln("N.labelToUnicode([%d] %s) errors %04lx missing UIDNA_ERRO R_LABEL_HAS_DOT",
766 (int)i, testCase.s, (long)uNLInfo.getErrors()); 769 (int)i, testCase.s, (long)uNLInfo.getErrors());
767 continue; 770 continue;
768 } 771 }
769 } 772 }
770 if(uT.indexOf((UChar)0x2e)<0) { 773 if(uT.indexOf((UChar)0x2e)<0) {
771 if(uT!=uTL || uTInfo.getErrors()!=uTLInfo.getErrors()) { 774 if(uT!=uTL || uTInfo.getErrors()!=uTLInfo.getErrors()) {
772 prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); 775 prettify(uT).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer ));
773 prettify(uTL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2)) ; 776 prettify(uTL).extract(0, 0x7fffffff, buffer2, UPRV_LENGTHOF(buff er2));
774 errln("T.nameToUnicode([%d] %s)!=T.labelToUnicode() " 777 errln("T.nameToUnicode([%d] %s)!=T.labelToUnicode() "
775 "(errors %04lx vs %04lx) %s vs. %s", 778 "(errors %04lx vs %04lx) %s vs. %s",
776 (int)i, testCase.s, uTInfo.getErrors(), uTLInfo.getErrors( ), buffer, buffer2); 779 (int)i, testCase.s, uTInfo.getErrors(), uTLInfo.getErrors( ), buffer, buffer2);
777 continue; 780 continue;
778 } 781 }
779 } else { 782 } else {
780 if((uTLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) { 783 if((uTLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) {
781 errln("T.labelToUnicode([%d] %s) errors %04lx missing UIDNA_ERRO R_LABEL_HAS_DOT", 784 errln("T.labelToUnicode([%d] %s) errors %04lx missing UIDNA_ERRO R_LABEL_HAS_DOT",
782 (int)i, testCase.s, (long)uTLInfo.getErrors()); 785 (int)i, testCase.s, (long)uTLInfo.getErrors());
783 continue; 786 continue;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 ) { 875 ) {
873 errln("%s.xyzUTF8([%d] %s) vs. UTF-16 processing different isTransit ionalDifferent()", 876 errln("%s.xyzUTF8([%d] %s) vs. UTF-16 processing different isTransit ionalDifferent()",
874 testCase.o, (int)i, testCase.s); 877 testCase.o, (int)i, testCase.s);
875 continue; 878 continue;
876 } 879 }
877 #endif 880 #endif
878 } 881 }
879 } 882 }
880 883
881 #endif // UCONFIG_NO_IDNA 884 #endif // UCONFIG_NO_IDNA
OLDNEW
« no previous file with comments | « source/test/intltest/ustrtest.cpp ('k') | source/test/intltest/utxttest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698