X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/4388f060552cc537e71e957d32f35e9d75a61233..a0b4f637ba1a6c3c5651b61a69303b029bacf7d3:/icuSources/test/intltest/uts46test.cpp diff --git a/icuSources/test/intltest/uts46test.cpp b/icuSources/test/intltest/uts46test.cpp index 1039acdc..5bdf305a 100644 --- a/icuSources/test/intltest/uts46test.cpp +++ b/icuSources/test/intltest/uts46test.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 2010-2011, International Business Machines +* Copyright (C) 2010-2014, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * file name: uts46test.cpp @@ -25,8 +25,7 @@ #include "unicode/uidna.h" #include "unicode/unistr.h" #include "intltest.h" - -#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) +#include "cmemory.h" class UTS46Test : public IntlTest { public: @@ -147,7 +146,7 @@ void UTS46Test::TestAPI() { } // UTF-8 char buffer[100]; - TestCheckedArrayByteSink sink(buffer, LENGTHOF(buffer)); + TestCheckedArrayByteSink sink(buffer, UPRV_LENGTHOF(buffer)); errorCode=U_ZERO_ERROR; nontrans->labelToUnicodeUTF8(StringPiece(NULL, 5), sink, info, errorCode); if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || sink.NumberOfBytesWritten()!=0) { @@ -214,7 +213,7 @@ void UTS46Test::TestNotSTD3() { UNICODE_STRING_SIMPLE("\\u0000a_2+2=4\\u000A.essen.net").unescape() || info.hasErrors() ) { - prettify(result).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); + prettify(result).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer)); errln("notSTD3.nameToUnicode(non-LDH ASCII) unexpected errors %04lx string %s", (long)info.getErrors(), buffer); } @@ -228,7 +227,7 @@ void UTS46Test::TestNotSTD3() { input=UNICODE_STRING_SIMPLE("a\\u2260b\\u226Ec\\u226Fd").unescape(); not3->nameToUnicode(input, result, info, errorCode); if(result!=input || info.hasErrors()) { - prettify(result).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer)); + prettify(result).extract(0, 0x7fffffff, buffer, UPRV_LENGTHOF(buffer)); errln("notSTD3.nameToUnicode(equiv to non-LDH ASCII) unexpected errors %04lx string %s", (long)info.getErrors(), buffer); } @@ -466,6 +465,9 @@ static const TestCase testCases[]={ "1234567890123456789012345678901234567890123456789012345678901", UIDNA_ERROR_LABEL_TOO_LONG|UIDNA_ERROR_DOMAIN_NAME_TOO_LONG }, // hyphen errors and empty-label errors + // Ticket #10883: ToUnicode also checks for empty labels. + { ".", "B", ".", UIDNA_ERROR_EMPTY_LABEL }, + { "\\uFF0E", "B", ".", UIDNA_ERROR_EMPTY_LABEL }, // "xn---q----jra"=="-q--a-umlaut-" { "a.b..-q--a-.e", "B", "a.b..-q--a-.e", UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN| @@ -477,11 +479,13 @@ static const TestCase testCases[]={ UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN| UIDNA_ERROR_HYPHEN_3_4 }, { "a..c", "B", "a..c", UIDNA_ERROR_EMPTY_LABEL }, + { "a.xn--.c", "B", "a..c", UIDNA_ERROR_EMPTY_LABEL }, { "a.-b.", "B", "a.-b.", UIDNA_ERROR_LEADING_HYPHEN }, { "a.b-.c", "B", "a.b-.c", UIDNA_ERROR_TRAILING_HYPHEN }, { "a.-.c", "B", "a.-.c", UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN }, { "a.bc--de.f", "B", "a.bc--de.f", UIDNA_ERROR_HYPHEN_3_4 }, { "\\u00E4.\\u00AD.c", "B", "\\u00E4..c", UIDNA_ERROR_EMPTY_LABEL }, + { "\\u00E4.xn--.c", "B", "\\u00E4..c", UIDNA_ERROR_EMPTY_LABEL }, { "\\u00E4.-b.", "B", "\\u00E4.-b.", UIDNA_ERROR_LEADING_HYPHEN }, { "\\u00E4.b-.c", "B", "\\u00E4.b-.c", UIDNA_ERROR_TRAILING_HYPHEN }, { "\\u00E4.-.c", "B", "\\u00E4.-.c", UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN }, @@ -581,7 +585,7 @@ void UTS46Test::TestSomeCases() { IcuTestErrorCode errorCode(*this, "TestSomeCases"); char buffer[400], buffer2[400]; int32_t i; - for(i=0; i