127f654740f2a26ad62a5c155af9199af9e69b889claireho/*
227f654740f2a26ad62a5c155af9199af9e69b889claireho*******************************************************************************
359d709d503bab6e2b61931737e662dd293b40578ccornelius*   Copyright (C) 2010-2014, International Business Machines
427f654740f2a26ad62a5c155af9199af9e69b889claireho*   Corporation and others.  All Rights Reserved.
527f654740f2a26ad62a5c155af9199af9e69b889claireho*******************************************************************************
627f654740f2a26ad62a5c155af9199af9e69b889claireho*   file name:  uts46test.cpp
727f654740f2a26ad62a5c155af9199af9e69b889claireho*   encoding:   US-ASCII
827f654740f2a26ad62a5c155af9199af9e69b889claireho*   tab size:   8 (not used)
927f654740f2a26ad62a5c155af9199af9e69b889claireho*   indentation:4
1027f654740f2a26ad62a5c155af9199af9e69b889claireho*
1127f654740f2a26ad62a5c155af9199af9e69b889claireho*   created on: 2010may05
1227f654740f2a26ad62a5c155af9199af9e69b889claireho*   created by: Markus W. Scherer
1327f654740f2a26ad62a5c155af9199af9e69b889claireho*/
1427f654740f2a26ad62a5c155af9199af9e69b889claireho
1527f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/utypes.h"
1627f654740f2a26ad62a5c155af9199af9e69b889claireho
1727f654740f2a26ad62a5c155af9199af9e69b889claireho#if !UCONFIG_NO_IDNA
1827f654740f2a26ad62a5c155af9199af9e69b889claireho
1927f654740f2a26ad62a5c155af9199af9e69b889claireho#include <string.h>
2027f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/bytestream.h"
2127f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/idna.h"
2227f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/localpointer.h"
2327f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/std_string.h"
2427f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/stringpiece.h"
2527f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/uidna.h"
2627f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/unistr.h"
2727f654740f2a26ad62a5c155af9199af9e69b889claireho#include "intltest.h"
2827f654740f2a26ad62a5c155af9199af9e69b889claireho
2927f654740f2a26ad62a5c155af9199af9e69b889claireho#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
3027f654740f2a26ad62a5c155af9199af9e69b889claireho
3127f654740f2a26ad62a5c155af9199af9e69b889clairehoclass UTS46Test : public IntlTest {
3227f654740f2a26ad62a5c155af9199af9e69b889clairehopublic:
3327f654740f2a26ad62a5c155af9199af9e69b889claireho    UTS46Test() : trans(NULL), nontrans(NULL) {}
3427f654740f2a26ad62a5c155af9199af9e69b889claireho    virtual ~UTS46Test();
3527f654740f2a26ad62a5c155af9199af9e69b889claireho
3627f654740f2a26ad62a5c155af9199af9e69b889claireho    void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=NULL);
3727f654740f2a26ad62a5c155af9199af9e69b889claireho    void TestAPI();
3827f654740f2a26ad62a5c155af9199af9e69b889claireho    void TestNotSTD3();
3927f654740f2a26ad62a5c155af9199af9e69b889claireho    void TestSomeCases();
4027f654740f2a26ad62a5c155af9199af9e69b889clairehoprivate:
4127f654740f2a26ad62a5c155af9199af9e69b889claireho    IDNA *trans, *nontrans;
4227f654740f2a26ad62a5c155af9199af9e69b889claireho};
4327f654740f2a26ad62a5c155af9199af9e69b889claireho
4427f654740f2a26ad62a5c155af9199af9e69b889clairehoextern IntlTest *createUTS46Test() {
4527f654740f2a26ad62a5c155af9199af9e69b889claireho    return new UTS46Test();
4627f654740f2a26ad62a5c155af9199af9e69b889claireho}
4727f654740f2a26ad62a5c155af9199af9e69b889claireho
4827f654740f2a26ad62a5c155af9199af9e69b889clairehoUTS46Test::~UTS46Test() {
4927f654740f2a26ad62a5c155af9199af9e69b889claireho    delete trans;
5027f654740f2a26ad62a5c155af9199af9e69b889claireho    delete nontrans;
5127f654740f2a26ad62a5c155af9199af9e69b889claireho}
5227f654740f2a26ad62a5c155af9199af9e69b889claireho
5327f654740f2a26ad62a5c155af9199af9e69b889clairehovoid UTS46Test::runIndexedTest(int32_t index, UBool exec, const char *&name, char * /*par*/) {
5427f654740f2a26ad62a5c155af9199af9e69b889claireho    if(exec) {
5527f654740f2a26ad62a5c155af9199af9e69b889claireho        logln("TestSuite UTS46Test: ");
5627f654740f2a26ad62a5c155af9199af9e69b889claireho        if(trans==NULL) {
5727f654740f2a26ad62a5c155af9199af9e69b889claireho            IcuTestErrorCode errorCode(*this, "init/createUTS46Instance()");
5883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius            uint32_t commonOptions=
5983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius                UIDNA_USE_STD3_RULES|UIDNA_CHECK_BIDI|
6083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius                UIDNA_CHECK_CONTEXTJ|UIDNA_CHECK_CONTEXTO;
6183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius            trans=IDNA::createUTS46Instance(commonOptions, errorCode);
6227f654740f2a26ad62a5c155af9199af9e69b889claireho            nontrans=IDNA::createUTS46Instance(
6383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius                commonOptions|
6427f654740f2a26ad62a5c155af9199af9e69b889claireho                UIDNA_NONTRANSITIONAL_TO_ASCII|UIDNA_NONTRANSITIONAL_TO_UNICODE,
6527f654740f2a26ad62a5c155af9199af9e69b889claireho                errorCode);
6627f654740f2a26ad62a5c155af9199af9e69b889claireho            if(errorCode.logDataIfFailureAndReset("createUTS46Instance()")) {
6727f654740f2a26ad62a5c155af9199af9e69b889claireho                name="";
6827f654740f2a26ad62a5c155af9199af9e69b889claireho                return;
6927f654740f2a26ad62a5c155af9199af9e69b889claireho            }
7027f654740f2a26ad62a5c155af9199af9e69b889claireho        }
7127f654740f2a26ad62a5c155af9199af9e69b889claireho    }
7227f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE_AUTO_BEGIN;
7327f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE_AUTO(TestAPI);
7427f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE_AUTO(TestNotSTD3);
7527f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE_AUTO(TestSomeCases);
7627f654740f2a26ad62a5c155af9199af9e69b889claireho    TESTCASE_AUTO_END;
7727f654740f2a26ad62a5c155af9199af9e69b889claireho}
7827f654740f2a26ad62a5c155af9199af9e69b889claireho
7927f654740f2a26ad62a5c155af9199af9e69b889clairehoconst uint32_t severeErrors=
8027f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_LEADING_COMBINING_MARK|
8127f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_DISALLOWED|
8227f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_PUNYCODE|
8327f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_LABEL_HAS_DOT|
8427f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_INVALID_ACE_LABEL;
8527f654740f2a26ad62a5c155af9199af9e69b889claireho
8627f654740f2a26ad62a5c155af9199af9e69b889clairehostatic UBool isASCII(const UnicodeString &str) {
8727f654740f2a26ad62a5c155af9199af9e69b889claireho    const UChar *s=str.getBuffer();
8827f654740f2a26ad62a5c155af9199af9e69b889claireho    int32_t length=str.length();
8927f654740f2a26ad62a5c155af9199af9e69b889claireho    for(int32_t i=0; i<length; ++i) {
9027f654740f2a26ad62a5c155af9199af9e69b889claireho        if(s[i]>=0x80) {
9127f654740f2a26ad62a5c155af9199af9e69b889claireho            return FALSE;
9227f654740f2a26ad62a5c155af9199af9e69b889claireho        }
9327f654740f2a26ad62a5c155af9199af9e69b889claireho    }
9427f654740f2a26ad62a5c155af9199af9e69b889claireho    return TRUE;
9527f654740f2a26ad62a5c155af9199af9e69b889claireho}
9627f654740f2a26ad62a5c155af9199af9e69b889claireho
9727f654740f2a26ad62a5c155af9199af9e69b889clairehoclass TestCheckedArrayByteSink : public CheckedArrayByteSink {
9827f654740f2a26ad62a5c155af9199af9e69b889clairehopublic:
9927f654740f2a26ad62a5c155af9199af9e69b889claireho    TestCheckedArrayByteSink(char* outbuf, int32_t capacity)
10027f654740f2a26ad62a5c155af9199af9e69b889claireho            : CheckedArrayByteSink(outbuf, capacity), calledFlush(FALSE) {}
10127f654740f2a26ad62a5c155af9199af9e69b889claireho    virtual CheckedArrayByteSink& Reset() {
10227f654740f2a26ad62a5c155af9199af9e69b889claireho        CheckedArrayByteSink::Reset();
10327f654740f2a26ad62a5c155af9199af9e69b889claireho        calledFlush = FALSE;
10427f654740f2a26ad62a5c155af9199af9e69b889claireho        return *this;
10527f654740f2a26ad62a5c155af9199af9e69b889claireho    }
10627f654740f2a26ad62a5c155af9199af9e69b889claireho    virtual void Flush() { calledFlush = TRUE; }
10727f654740f2a26ad62a5c155af9199af9e69b889claireho    UBool calledFlush;
10827f654740f2a26ad62a5c155af9199af9e69b889claireho};
10927f654740f2a26ad62a5c155af9199af9e69b889claireho
11027f654740f2a26ad62a5c155af9199af9e69b889clairehovoid UTS46Test::TestAPI() {
11127f654740f2a26ad62a5c155af9199af9e69b889claireho    UErrorCode errorCode=U_ZERO_ERROR;
11227f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeString result;
11327f654740f2a26ad62a5c155af9199af9e69b889claireho    IDNAInfo info;
11427f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeString input=UNICODE_STRING_SIMPLE("www.eXample.cOm");
11527f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeString expected=UNICODE_STRING_SIMPLE("www.example.com");
11627f654740f2a26ad62a5c155af9199af9e69b889claireho    trans->nameToASCII(input, result, info, errorCode);
11727f654740f2a26ad62a5c155af9199af9e69b889claireho    if(U_FAILURE(errorCode) || info.hasErrors() || result!=expected) {
11827f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("T.nameToASCII(www.example.com) info.errors=%04lx result matches=%d %s",
11927f654740f2a26ad62a5c155af9199af9e69b889claireho              (long)info.getErrors(), result==expected, u_errorName(errorCode));
12027f654740f2a26ad62a5c155af9199af9e69b889claireho    }
12127f654740f2a26ad62a5c155af9199af9e69b889claireho    errorCode=U_USELESS_COLLATOR_ERROR;
12227f654740f2a26ad62a5c155af9199af9e69b889claireho    trans->nameToUnicode(input, result, info, errorCode);
12327f654740f2a26ad62a5c155af9199af9e69b889claireho    if(errorCode!=U_USELESS_COLLATOR_ERROR || !result.isBogus()) {
12427f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("T.nameToUnicode(U_FAILURE) did not preserve the errorCode "
12527f654740f2a26ad62a5c155af9199af9e69b889claireho              "or not result.setToBogus() - %s",
12627f654740f2a26ad62a5c155af9199af9e69b889claireho              u_errorName(errorCode));
12727f654740f2a26ad62a5c155af9199af9e69b889claireho    }
12827f654740f2a26ad62a5c155af9199af9e69b889claireho    errorCode=U_ZERO_ERROR;
12927f654740f2a26ad62a5c155af9199af9e69b889claireho    input.setToBogus();
13027f654740f2a26ad62a5c155af9199af9e69b889claireho    result=UNICODE_STRING_SIMPLE("quatsch");
13127f654740f2a26ad62a5c155af9199af9e69b889claireho    nontrans->labelToASCII(input, result, info, errorCode);
13227f654740f2a26ad62a5c155af9199af9e69b889claireho    if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || !result.isBogus()) {
13327f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("N.labelToASCII(bogus) did not set illegal-argument-error "
13427f654740f2a26ad62a5c155af9199af9e69b889claireho              "or not result.setToBogus() - %s",
13527f654740f2a26ad62a5c155af9199af9e69b889claireho              u_errorName(errorCode));
13627f654740f2a26ad62a5c155af9199af9e69b889claireho    }
13727f654740f2a26ad62a5c155af9199af9e69b889claireho    errorCode=U_ZERO_ERROR;
13827f654740f2a26ad62a5c155af9199af9e69b889claireho    input=UNICODE_STRING_SIMPLE("xn--bcher.de-65a");
13927f654740f2a26ad62a5c155af9199af9e69b889claireho    expected=UNICODE_STRING_SIMPLE("xn--bcher\\uFFFDde-65a").unescape();
14027f654740f2a26ad62a5c155af9199af9e69b889claireho    nontrans->labelToASCII(input, result, info, errorCode);
14127f654740f2a26ad62a5c155af9199af9e69b889claireho    if( U_FAILURE(errorCode) ||
14227f654740f2a26ad62a5c155af9199af9e69b889claireho        info.getErrors()!=(UIDNA_ERROR_LABEL_HAS_DOT|UIDNA_ERROR_INVALID_ACE_LABEL) ||
14327f654740f2a26ad62a5c155af9199af9e69b889claireho        result!=expected
14427f654740f2a26ad62a5c155af9199af9e69b889claireho    ) {
14527f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("N.labelToASCII(label-with-dot) failed with errors %04lx - %s",
14627f654740f2a26ad62a5c155af9199af9e69b889claireho              info.getErrors(), u_errorName(errorCode));
14727f654740f2a26ad62a5c155af9199af9e69b889claireho    }
14827f654740f2a26ad62a5c155af9199af9e69b889claireho    // UTF-8
14927f654740f2a26ad62a5c155af9199af9e69b889claireho    char buffer[100];
15027f654740f2a26ad62a5c155af9199af9e69b889claireho    TestCheckedArrayByteSink sink(buffer, LENGTHOF(buffer));
15127f654740f2a26ad62a5c155af9199af9e69b889claireho    errorCode=U_ZERO_ERROR;
15227f654740f2a26ad62a5c155af9199af9e69b889claireho    nontrans->labelToUnicodeUTF8(StringPiece(NULL, 5), sink, info, errorCode);
15327f654740f2a26ad62a5c155af9199af9e69b889claireho    if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR || sink.NumberOfBytesWritten()!=0) {
15427f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("N.labelToUnicodeUTF8(StringPiece(NULL, 5)) did not set illegal-argument-error ",
15527f654740f2a26ad62a5c155af9199af9e69b889claireho              "or did output something - %s",
15627f654740f2a26ad62a5c155af9199af9e69b889claireho              u_errorName(errorCode));
15727f654740f2a26ad62a5c155af9199af9e69b889claireho    }
15827f654740f2a26ad62a5c155af9199af9e69b889claireho
15927f654740f2a26ad62a5c155af9199af9e69b889claireho    sink.Reset();
16027f654740f2a26ad62a5c155af9199af9e69b889claireho    errorCode=U_ZERO_ERROR;
16127f654740f2a26ad62a5c155af9199af9e69b889claireho    nontrans->nameToASCII_UTF8(StringPiece(), sink, info, errorCode);
16227f654740f2a26ad62a5c155af9199af9e69b889claireho    if(U_FAILURE(errorCode) || sink.NumberOfBytesWritten()!=0 || !sink.calledFlush) {
16327f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("N.nameToASCII_UTF8(empty) failed - %s",
16427f654740f2a26ad62a5c155af9199af9e69b889claireho              u_errorName(errorCode));
16527f654740f2a26ad62a5c155af9199af9e69b889claireho    }
16627f654740f2a26ad62a5c155af9199af9e69b889claireho
16727f654740f2a26ad62a5c155af9199af9e69b889claireho    static const char s[]={ 0x61, (char)0xc3, (char)0x9f };
16827f654740f2a26ad62a5c155af9199af9e69b889claireho    sink.Reset();
16927f654740f2a26ad62a5c155af9199af9e69b889claireho    errorCode=U_USELESS_COLLATOR_ERROR;
17027f654740f2a26ad62a5c155af9199af9e69b889claireho    nontrans->nameToUnicodeUTF8(StringPiece(s, 3), sink, info, errorCode);
17127f654740f2a26ad62a5c155af9199af9e69b889claireho    if(errorCode!=U_USELESS_COLLATOR_ERROR || sink.NumberOfBytesWritten()!=0) {
17227f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("N.nameToUnicode_UTF8(U_FAILURE) did not preserve the errorCode "
17327f654740f2a26ad62a5c155af9199af9e69b889claireho              "or did output something - %s",
17427f654740f2a26ad62a5c155af9199af9e69b889claireho              u_errorName(errorCode));
17527f654740f2a26ad62a5c155af9199af9e69b889claireho    }
17627f654740f2a26ad62a5c155af9199af9e69b889claireho
17727f654740f2a26ad62a5c155af9199af9e69b889claireho    sink.Reset();
17827f654740f2a26ad62a5c155af9199af9e69b889claireho    errorCode=U_ZERO_ERROR;
17927f654740f2a26ad62a5c155af9199af9e69b889claireho    trans->labelToUnicodeUTF8(StringPiece(s, 3), sink, info, errorCode);
18027f654740f2a26ad62a5c155af9199af9e69b889claireho    if( U_FAILURE(errorCode) || sink.NumberOfBytesWritten()!=3 ||
18127f654740f2a26ad62a5c155af9199af9e69b889claireho        buffer[0]!=0x61 || buffer[1]!=0x73 || buffer[2]!=0x73 ||
18227f654740f2a26ad62a5c155af9199af9e69b889claireho        !sink.calledFlush
18327f654740f2a26ad62a5c155af9199af9e69b889claireho    ) {
18427f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("T.labelToUnicodeUTF8(a sharp-s) failed - %s",
18527f654740f2a26ad62a5c155af9199af9e69b889claireho              u_errorName(errorCode));
18627f654740f2a26ad62a5c155af9199af9e69b889claireho    }
18727f654740f2a26ad62a5c155af9199af9e69b889claireho
18827f654740f2a26ad62a5c155af9199af9e69b889claireho    sink.Reset();
18927f654740f2a26ad62a5c155af9199af9e69b889claireho    errorCode=U_ZERO_ERROR;
19027f654740f2a26ad62a5c155af9199af9e69b889claireho    // "eXampLe.cOm"
19127f654740f2a26ad62a5c155af9199af9e69b889claireho    static const char eX[]={ 0x65, 0x58, 0x61, 0x6d, 0x70, 0x4c, 0x65, 0x2e, 0x63, 0x4f, 0x6d, 0 };
19227f654740f2a26ad62a5c155af9199af9e69b889claireho    // "example.com"
19327f654740f2a26ad62a5c155af9199af9e69b889claireho    static const char ex[]={ 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d };
19427f654740f2a26ad62a5c155af9199af9e69b889claireho    trans->nameToUnicodeUTF8(eX, sink, info, errorCode);
19527f654740f2a26ad62a5c155af9199af9e69b889claireho    if( U_FAILURE(errorCode) || sink.NumberOfBytesWritten()!=11 ||
19627f654740f2a26ad62a5c155af9199af9e69b889claireho        0!=memcmp(ex, buffer, 11) || !sink.calledFlush
19727f654740f2a26ad62a5c155af9199af9e69b889claireho    ) {
19827f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("T.nameToUnicodeUTF8(eXampLe.cOm) failed - %s",
19927f654740f2a26ad62a5c155af9199af9e69b889claireho              u_errorName(errorCode));
20027f654740f2a26ad62a5c155af9199af9e69b889claireho    }
20127f654740f2a26ad62a5c155af9199af9e69b889claireho}
20227f654740f2a26ad62a5c155af9199af9e69b889claireho
20327f654740f2a26ad62a5c155af9199af9e69b889clairehovoid UTS46Test::TestNotSTD3() {
20427f654740f2a26ad62a5c155af9199af9e69b889claireho    IcuTestErrorCode errorCode(*this, "TestNotSTD3()");
20527f654740f2a26ad62a5c155af9199af9e69b889claireho    char buffer[400];
20627f654740f2a26ad62a5c155af9199af9e69b889claireho    LocalPointer<IDNA> not3(IDNA::createUTS46Instance(UIDNA_CHECK_BIDI, errorCode));
20727f654740f2a26ad62a5c155af9199af9e69b889claireho    if(errorCode.isFailure()) {
20827f654740f2a26ad62a5c155af9199af9e69b889claireho        return;
20927f654740f2a26ad62a5c155af9199af9e69b889claireho    }
21027f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeString input=UNICODE_STRING_SIMPLE("\\u0000A_2+2=4\\u000A.e\\u00DFen.net").unescape();
21127f654740f2a26ad62a5c155af9199af9e69b889claireho    UnicodeString result;
21227f654740f2a26ad62a5c155af9199af9e69b889claireho    IDNAInfo info;
21327f654740f2a26ad62a5c155af9199af9e69b889claireho    if( not3->nameToUnicode(input, result, info, errorCode)!=
21427f654740f2a26ad62a5c155af9199af9e69b889claireho            UNICODE_STRING_SIMPLE("\\u0000a_2+2=4\\u000A.essen.net").unescape() ||
21527f654740f2a26ad62a5c155af9199af9e69b889claireho        info.hasErrors()
21627f654740f2a26ad62a5c155af9199af9e69b889claireho    ) {
21727f654740f2a26ad62a5c155af9199af9e69b889claireho        prettify(result).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
21827f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("notSTD3.nameToUnicode(non-LDH ASCII) unexpected errors %04lx string %s",
21927f654740f2a26ad62a5c155af9199af9e69b889claireho              (long)info.getErrors(), buffer);
22027f654740f2a26ad62a5c155af9199af9e69b889claireho    }
22127f654740f2a26ad62a5c155af9199af9e69b889claireho    // A space (BiDi class WS) is not allowed in a BiDi domain name.
22227f654740f2a26ad62a5c155af9199af9e69b889claireho    input=UNICODE_STRING_SIMPLE("a z.xn--4db.edu");
22327f654740f2a26ad62a5c155af9199af9e69b889claireho    not3->nameToASCII(input, result, info, errorCode);
22427f654740f2a26ad62a5c155af9199af9e69b889claireho    if(result!=input || info.getErrors()!=UIDNA_ERROR_BIDI) {
22527f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("notSTD3.nameToASCII(ASCII-with-space.alef.edu) failed");
22627f654740f2a26ad62a5c155af9199af9e69b889claireho    }
22727f654740f2a26ad62a5c155af9199af9e69b889claireho    // Characters that are canonically equivalent to sequences with non-LDH ASCII.
22827f654740f2a26ad62a5c155af9199af9e69b889claireho    input=UNICODE_STRING_SIMPLE("a\\u2260b\\u226Ec\\u226Fd").unescape();
22927f654740f2a26ad62a5c155af9199af9e69b889claireho    not3->nameToUnicode(input, result, info, errorCode);
23027f654740f2a26ad62a5c155af9199af9e69b889claireho    if(result!=input || info.hasErrors()) {
23127f654740f2a26ad62a5c155af9199af9e69b889claireho        prettify(result).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
23227f654740f2a26ad62a5c155af9199af9e69b889claireho        errln("notSTD3.nameToUnicode(equiv to non-LDH ASCII) unexpected errors %04lx string %s",
23327f654740f2a26ad62a5c155af9199af9e69b889claireho              (long)info.getErrors(), buffer);
23427f654740f2a26ad62a5c155af9199af9e69b889claireho    }
23527f654740f2a26ad62a5c155af9199af9e69b889claireho}
23627f654740f2a26ad62a5c155af9199af9e69b889claireho
23727f654740f2a26ad62a5c155af9199af9e69b889clairehostruct TestCase {
23827f654740f2a26ad62a5c155af9199af9e69b889claireho    // Input string and options string (Nontransitional/Transitional/Both).
23927f654740f2a26ad62a5c155af9199af9e69b889claireho    const char *s, *o;
24027f654740f2a26ad62a5c155af9199af9e69b889claireho    // Expected Unicode result string.
24127f654740f2a26ad62a5c155af9199af9e69b889claireho    const char *u;
24227f654740f2a26ad62a5c155af9199af9e69b889claireho    uint32_t errors;
24327f654740f2a26ad62a5c155af9199af9e69b889claireho};
24427f654740f2a26ad62a5c155af9199af9e69b889claireho
24527f654740f2a26ad62a5c155af9199af9e69b889clairehostatic const TestCase testCases[]={
24627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "www.eXample.cOm", "B",  // all ASCII
24727f654740f2a26ad62a5c155af9199af9e69b889claireho      "www.example.com", 0 },
24827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "B\\u00FCcher.de", "B",  // u-umlaut
24927f654740f2a26ad62a5c155af9199af9e69b889claireho      "b\\u00FCcher.de", 0 },
25027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u00D6BB", "B",  // O-umlaut
25127f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00F6bb", 0 },
25227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "fa\\u00DF.de", "N",  // sharp s
25327f654740f2a26ad62a5c155af9199af9e69b889claireho      "fa\\u00DF.de", 0 },
25427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "fa\\u00DF.de", "T",  // sharp s
25527f654740f2a26ad62a5c155af9199af9e69b889claireho      "fass.de", 0 },
25627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "XN--fA-hia.dE", "B",  // sharp s in Punycode
25727f654740f2a26ad62a5c155af9199af9e69b889claireho      "fa\\u00DF.de", 0 },
25827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u03B2\\u03CC\\u03BB\\u03BF\\u03C2.com", "N",  // Greek with final sigma
25927f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u03B2\\u03CC\\u03BB\\u03BF\\u03C2.com", 0 },
26027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u03B2\\u03CC\\u03BB\\u03BF\\u03C2.com", "T",  // Greek with final sigma
26127f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u03B2\\u03CC\\u03BB\\u03BF\\u03C3.com", 0 },
26227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--nxasmm1c", "B",  // Greek with final sigma in Punycode
26327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u03B2\\u03CC\\u03BB\\u03BF\\u03C2", 0 },
26427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "www.\\u0DC1\\u0DCA\\u200D\\u0DBB\\u0DD3.com", "N",  // "Sri" in "Sri Lanka" has a ZWJ
26527f654740f2a26ad62a5c155af9199af9e69b889claireho      "www.\\u0DC1\\u0DCA\\u200D\\u0DBB\\u0DD3.com", 0 },
26627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "www.\\u0DC1\\u0DCA\\u200D\\u0DBB\\u0DD3.com", "T",  // "Sri" in "Sri Lanka" has a ZWJ
26727f654740f2a26ad62a5c155af9199af9e69b889claireho      "www.\\u0DC1\\u0DCA\\u0DBB\\u0DD3.com", 0 },
26827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "www.xn--10cl1a0b660p.com", "B",  // "Sri" in Punycode
26927f654740f2a26ad62a5c155af9199af9e69b889claireho      "www.\\u0DC1\\u0DCA\\u200D\\u0DBB\\u0DD3.com", 0 },
27027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0646\\u0627\\u0645\\u0647\\u200C\\u0627\\u06CC", "N",  // ZWNJ
27127f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0646\\u0627\\u0645\\u0647\\u200C\\u0627\\u06CC", 0 },
27227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0646\\u0627\\u0645\\u0647\\u200C\\u0627\\u06CC", "T",  // ZWNJ
27327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0646\\u0627\\u0645\\u0647\\u0627\\u06CC", 0 },
27427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--mgba3gch31f060k.com", "B",  // ZWNJ in Punycode
27527f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0646\\u0627\\u0645\\u0647\\u200C\\u0627\\u06CC.com", 0 },
27627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.b\\uFF0Ec\\u3002d\\uFF61", "B",
27727f654740f2a26ad62a5c155af9199af9e69b889claireho      "a.b.c.d.", 0 },
27827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "U\\u0308.xn--tda", "B",  // U+umlaut.u-umlaut
27927f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00FC.\\u00FC", 0 },
28027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--u-ccb", "B",  // u+umlaut in Punycode
28127f654740f2a26ad62a5c155af9199af9e69b889claireho      "xn--u-ccb\\uFFFD", UIDNA_ERROR_INVALID_ACE_LABEL },
28227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a\\u2488com", "B",  // contains 1-dot
28327f654740f2a26ad62a5c155af9199af9e69b889claireho      "a\\uFFFDcom", UIDNA_ERROR_DISALLOWED },
28427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--a-ecp.ru", "B",  // contains 1-dot in Punycode
28527f654740f2a26ad62a5c155af9199af9e69b889claireho      "xn--a-ecp\\uFFFD.ru", UIDNA_ERROR_INVALID_ACE_LABEL },
28627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--0.pt", "B",  // invalid Punycode
28727f654740f2a26ad62a5c155af9199af9e69b889claireho      "xn--0\\uFFFD.pt", UIDNA_ERROR_PUNYCODE },
28827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--a.pt", "B",  // U+0080
28927f654740f2a26ad62a5c155af9199af9e69b889claireho      "xn--a\\uFFFD.pt", UIDNA_ERROR_INVALID_ACE_LABEL },
29027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--a-\\u00C4.pt", "B",  // invalid Punycode
29127f654740f2a26ad62a5c155af9199af9e69b889claireho      "xn--a-\\u00E4.pt", UIDNA_ERROR_PUNYCODE },
29227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u65E5\\u672C\\u8A9E\\u3002\\uFF2A\\uFF30", "B",  // Japanese with fullwidth ".jp"
29327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u65E5\\u672C\\u8A9E.jp", 0 },
29427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u2615", "B", "\\u2615", 0 },  // Unicode 4.0 HOT BEVERAGE
29527f654740f2a26ad62a5c155af9199af9e69b889claireho    // some characters are disallowed because they are canonically equivalent
29627f654740f2a26ad62a5c155af9199af9e69b889claireho    // to sequences with non-LDH ASCII
29727f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a\\u2260b\\u226Ec\\u226Fd", "B",
29827f654740f2a26ad62a5c155af9199af9e69b889claireho      "a\\uFFFDb\\uFFFDc\\uFFFDd", UIDNA_ERROR_DISALLOWED },
29927f654740f2a26ad62a5c155af9199af9e69b889claireho    // many deviation characters, test the special mapping code
30027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "1.a\\u00DF\\u200C\\u200Db\\u200C\\u200Dc\\u00DF\\u00DF\\u00DF\\u00DFd"
30127f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u03C2\\u03C3\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFe"
30227f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFx"
30327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFy"
30427f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u0302\\u00DFz", "N",
30527f654740f2a26ad62a5c155af9199af9e69b889claireho      "1.a\\u00DF\\u200C\\u200Db\\u200C\\u200Dc\\u00DF\\u00DF\\u00DF\\u00DFd"
30627f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u03C2\\u03C3\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFe"
30727f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFx"
30827f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFy"
30927f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u0302\\u00DFz",
31027f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_LABEL_TOO_LONG|UIDNA_ERROR_CONTEXTJ },
31127f654740f2a26ad62a5c155af9199af9e69b889claireho    { "1.a\\u00DF\\u200C\\u200Db\\u200C\\u200Dc\\u00DF\\u00DF\\u00DF\\u00DFd"
31227f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u03C2\\u03C3\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFe"
31327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFx"
31427f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DFy"
31527f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u00DF\\u0302\\u00DFz", "T",
31627f654740f2a26ad62a5c155af9199af9e69b889claireho      "1.assbcssssssssd"
31727f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u03C3\\u03C3sssssssssssssssse"
31827f654740f2a26ad62a5c155af9199af9e69b889claireho      "ssssssssssssssssssssx"
31927f654740f2a26ad62a5c155af9199af9e69b889claireho      "ssssssssssssssssssssy"
32027f654740f2a26ad62a5c155af9199af9e69b889claireho      "sssssssssssssss\\u015Dssz", UIDNA_ERROR_LABEL_TOO_LONG },
32127f654740f2a26ad62a5c155af9199af9e69b889claireho    // "xn--bss" with deviation characters
32227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u200Cx\\u200Dn\\u200C-\\u200D-b\\u00DF", "N",
32327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u200Cx\\u200Dn\\u200C-\\u200D-b\\u00DF", UIDNA_ERROR_CONTEXTJ },
32427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u200Cx\\u200Dn\\u200C-\\u200D-b\\u00DF", "T",
32527f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u5919", 0 },
32627f654740f2a26ad62a5c155af9199af9e69b889claireho    // "xn--bssffl" written as:
32727f654740f2a26ad62a5c155af9199af9e69b889claireho    // 02E3 MODIFIER LETTER SMALL X
32827f654740f2a26ad62a5c155af9199af9e69b889claireho    // 034F COMBINING GRAPHEME JOINER (ignored)
32927f654740f2a26ad62a5c155af9199af9e69b889claireho    // 2115 DOUBLE-STRUCK CAPITAL N
33027f654740f2a26ad62a5c155af9199af9e69b889claireho    // 200B ZERO WIDTH SPACE (ignored)
33127f654740f2a26ad62a5c155af9199af9e69b889claireho    // FE63 SMALL HYPHEN-MINUS
33227f654740f2a26ad62a5c155af9199af9e69b889claireho    // 00AD SOFT HYPHEN (ignored)
33327f654740f2a26ad62a5c155af9199af9e69b889claireho    // FF0D FULLWIDTH HYPHEN-MINUS
33427f654740f2a26ad62a5c155af9199af9e69b889claireho    // 180C MONGOLIAN FREE VARIATION SELECTOR TWO (ignored)
33527f654740f2a26ad62a5c155af9199af9e69b889claireho    // 212C SCRIPT CAPITAL B
33627f654740f2a26ad62a5c155af9199af9e69b889claireho    // FE00 VARIATION SELECTOR-1 (ignored)
33727f654740f2a26ad62a5c155af9199af9e69b889claireho    // 017F LATIN SMALL LETTER LONG S
33827f654740f2a26ad62a5c155af9199af9e69b889claireho    // 2064 INVISIBLE PLUS (ignored)
33927f654740f2a26ad62a5c155af9199af9e69b889claireho    // 1D530 MATHEMATICAL FRAKTUR SMALL S
34027f654740f2a26ad62a5c155af9199af9e69b889claireho    // E01EF VARIATION SELECTOR-256 (ignored)
34127f654740f2a26ad62a5c155af9199af9e69b889claireho    // FB04 LATIN SMALL LIGATURE FFL
34227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u02E3\\u034F\\u2115\\u200B\\uFE63\\u00AD\\uFF0D\\u180C"
34327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u212C\\uFE00\\u017F\\u2064\\U0001D530\\U000E01EF\\uFB04", "B",
34427f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u5921\\u591E\\u591C\\u5919", 0 },
34527f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
34627f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
34727f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
34827f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901", "B",
34927f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
35027f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
35127f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
35227f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901", 0 },
35327f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
35427f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
35527f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
35627f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901.", "B",
35727f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
35827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
35927f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
36027f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901.", 0 },
36127f654740f2a26ad62a5c155af9199af9e69b889claireho    // Domain name >256 characters, forces slow path in UTF-8 processing.
36227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
36327f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
36427f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
36527f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
36627f654740f2a26ad62a5c155af9199af9e69b889claireho      "12345678901234567890123456789012345678901234567890123456789012", "B",
36727f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
36827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
36927f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
37027f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
37127f654740f2a26ad62a5c155af9199af9e69b889claireho      "12345678901234567890123456789012345678901234567890123456789012",
37227f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_DOMAIN_NAME_TOO_LONG },
37327f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
37427f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
37527f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
37627f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
37727f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789\\u05D0", "B",
37827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
37927f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
38027f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
38127f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
38227f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789\\u05D0",
38327f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_DOMAIN_NAME_TOO_LONG|UIDNA_ERROR_BIDI },
38427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
38527f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901234."
38627f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
38727f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890", "B",
38827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
38927f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901234."
39027f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
39127f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890",
39227f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_LABEL_TOO_LONG },
39327f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
39427f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901234."
39527f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
39627f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890.", "B",
39727f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
39827f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901234."
39927f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
40027f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890.",
40127f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_LABEL_TOO_LONG },
40227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
40327f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901234."
40427f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
40527f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901", "B",
40627f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
40727f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901234."
40827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
40927f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901",
41027f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_LABEL_TOO_LONG|UIDNA_ERROR_DOMAIN_NAME_TOO_LONG },
41127f654740f2a26ad62a5c155af9199af9e69b889claireho    // label length 63: xn--1234567890123456789012345678901234567890123456789012345-9te
41227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u00E41234567890123456789012345678901234567890123456789012345", "B",
41327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u00E41234567890123456789012345678901234567890123456789012345", 0 },
41427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "1234567890\\u00E41234567890123456789012345678901234567890123456", "B",
41527f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E41234567890123456789012345678901234567890123456", UIDNA_ERROR_LABEL_TOO_LONG },
41627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
41727f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E4123456789012345678901234567890123456789012345."
41827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
41927f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901", "B",
42027f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
42127f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E4123456789012345678901234567890123456789012345."
42227f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
42327f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901", 0 },
42427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
42527f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E4123456789012345678901234567890123456789012345."
42627f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
42727f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901.", "B",
42827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
42927f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E4123456789012345678901234567890123456789012345."
43027f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
43127f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901.", 0 },
43227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
43327f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E4123456789012345678901234567890123456789012345."
43427f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
43527f654740f2a26ad62a5c155af9199af9e69b889claireho      "12345678901234567890123456789012345678901234567890123456789012", "B",
43627f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
43727f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E4123456789012345678901234567890123456789012345."
43827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
43927f654740f2a26ad62a5c155af9199af9e69b889claireho      "12345678901234567890123456789012345678901234567890123456789012",
44027f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_DOMAIN_NAME_TOO_LONG },
44127f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
44227f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E41234567890123456789012345678901234567890123456."
44327f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
44427f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890", "B",
44527f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
44627f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E41234567890123456789012345678901234567890123456."
44727f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
44827f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890",
44927f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_LABEL_TOO_LONG },
45027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
45127f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E41234567890123456789012345678901234567890123456."
45227f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
45327f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890.", "B",
45427f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
45527f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E41234567890123456789012345678901234567890123456."
45627f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
45727f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890.",
45827f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_LABEL_TOO_LONG },
45927f654740f2a26ad62a5c155af9199af9e69b889claireho    { "123456789012345678901234567890123456789012345678901234567890123."
46027f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E41234567890123456789012345678901234567890123456."
46127f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
46227f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901", "B",
46327f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
46427f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890\\u00E41234567890123456789012345678901234567890123456."
46527f654740f2a26ad62a5c155af9199af9e69b889claireho      "123456789012345678901234567890123456789012345678901234567890123."
46627f654740f2a26ad62a5c155af9199af9e69b889claireho      "1234567890123456789012345678901234567890123456789012345678901",
46727f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_LABEL_TOO_LONG|UIDNA_ERROR_DOMAIN_NAME_TOO_LONG },
46827f654740f2a26ad62a5c155af9199af9e69b889claireho    // hyphen errors and empty-label errors
46959d709d503bab6e2b61931737e662dd293b40578ccornelius    { ".", "B", ".", UIDNA_ERROR_EMPTY_LABEL },
47059d709d503bab6e2b61931737e662dd293b40578ccornelius    { "\\uFF0E", "B", ".", UIDNA_ERROR_EMPTY_LABEL },
47127f654740f2a26ad62a5c155af9199af9e69b889claireho    // "xn---q----jra"=="-q--a-umlaut-"
47227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.b..-q--a-.e", "B", "a.b..-q--a-.e",
47327f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN|
47427f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_HYPHEN_3_4 },
47527f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.b..-q--\\u00E4-.e", "B", "a.b..-q--\\u00E4-.e",
47627f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN|
47727f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_HYPHEN_3_4 },
47827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.b..xn---q----jra.e", "B", "a.b..-q--\\u00E4-.e",
47927f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_EMPTY_LABEL|UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN|
48027f654740f2a26ad62a5c155af9199af9e69b889claireho      UIDNA_ERROR_HYPHEN_3_4 },
48127f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a..c", "B", "a..c", UIDNA_ERROR_EMPTY_LABEL },
48227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.-b.", "B", "a.-b.", UIDNA_ERROR_LEADING_HYPHEN },
48327f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.b-.c", "B", "a.b-.c", UIDNA_ERROR_TRAILING_HYPHEN },
48427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.-.c", "B", "a.-.c", UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN },
48527f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.bc--de.f", "B", "a.bc--de.f", UIDNA_ERROR_HYPHEN_3_4 },
48627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u00E4.\\u00AD.c", "B", "\\u00E4..c", UIDNA_ERROR_EMPTY_LABEL },
48727f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u00E4.-b.", "B", "\\u00E4.-b.", UIDNA_ERROR_LEADING_HYPHEN },
48827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u00E4.b-.c", "B", "\\u00E4.b-.c", UIDNA_ERROR_TRAILING_HYPHEN },
48927f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u00E4.-.c", "B", "\\u00E4.-.c", UIDNA_ERROR_LEADING_HYPHEN|UIDNA_ERROR_TRAILING_HYPHEN },
49027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u00E4.bc--de.f", "B", "\\u00E4.bc--de.f", UIDNA_ERROR_HYPHEN_3_4 },
49127f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.b.\\u0308c.d", "B", "a.b.\\uFFFDc.d", UIDNA_ERROR_LEADING_COMBINING_MARK },
49227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a.b.xn--c-bcb.d", "B",
49327f654740f2a26ad62a5c155af9199af9e69b889claireho      "a.b.xn--c-bcb\\uFFFD.d", UIDNA_ERROR_LEADING_COMBINING_MARK|UIDNA_ERROR_INVALID_ACE_LABEL },
49427f654740f2a26ad62a5c155af9199af9e69b889claireho    // BiDi
49527f654740f2a26ad62a5c155af9199af9e69b889claireho    { "A0", "B", "a0", 0 },
49627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "0A", "B", "0a", 0 },  // all-LTR is ok to start with a digit (EN)
49727f654740f2a26ad62a5c155af9199af9e69b889claireho    { "0A.\\u05D0", "B",  // ASCII label does not start with L/R/AL
49827f654740f2a26ad62a5c155af9199af9e69b889claireho      "0a.\\u05D0", UIDNA_ERROR_BIDI },
49927f654740f2a26ad62a5c155af9199af9e69b889claireho    { "c.xn--0-eha.xn--4db", "B",  // 2nd label does not start with L/R/AL
50027f654740f2a26ad62a5c155af9199af9e69b889claireho      "c.0\\u00FC.\\u05D0", UIDNA_ERROR_BIDI },
50127f654740f2a26ad62a5c155af9199af9e69b889claireho    { "b-.\\u05D0", "B",  // label does not end with L/EN
50227f654740f2a26ad62a5c155af9199af9e69b889claireho      "b-.\\u05D0", UIDNA_ERROR_TRAILING_HYPHEN|UIDNA_ERROR_BIDI },
50327f654740f2a26ad62a5c155af9199af9e69b889claireho    { "d.xn----dha.xn--4db", "B",  // 2nd label does not end with L/EN
50427f654740f2a26ad62a5c155af9199af9e69b889claireho      "d.\\u00FC-.\\u05D0", UIDNA_ERROR_TRAILING_HYPHEN|UIDNA_ERROR_BIDI },
50527f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a\\u05D0", "B", "a\\u05D0", UIDNA_ERROR_BIDI },  // first dir != last dir
50627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D0\\u05C7", "B", "\\u05D0\\u05C7", 0 },
50727f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D09\\u05C7", "B", "\\u05D09\\u05C7", 0 },
50827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D0a\\u05C7", "B", "\\u05D0a\\u05C7", UIDNA_ERROR_BIDI },  // first dir != last dir
50927f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D0\\u05EA", "B", "\\u05D0\\u05EA", 0 },
51027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D0\\u05F3\\u05EA", "B", "\\u05D0\\u05F3\\u05EA", 0 },
51127f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a\\u05D0Tz", "B", "a\\u05D0tz", UIDNA_ERROR_BIDI },  // mixed dir
51227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D0T\\u05EA", "B", "\\u05D0t\\u05EA", UIDNA_ERROR_BIDI },  // mixed dir
51327f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D07\\u05EA", "B", "\\u05D07\\u05EA", 0 },
51427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D0\\u0667\\u05EA", "B", "\\u05D0\\u0667\\u05EA", 0 },  // Arabic 7 in the middle
51527f654740f2a26ad62a5c155af9199af9e69b889claireho    { "a7\\u0667z", "B", "a7\\u0667z", UIDNA_ERROR_BIDI },  // AN digit in LTR
51627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u05D07\\u0667\\u05EA", "B",  // mixed EN/AN digits in RTL
51727f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u05D07\\u0667\\u05EA", UIDNA_ERROR_BIDI },
51827f654740f2a26ad62a5c155af9199af9e69b889claireho    // ZWJ
51927f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0BB9\\u0BCD\\u200D", "N", "\\u0BB9\\u0BCD\\u200D", 0 },  // Virama+ZWJ
52027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0BB9\\u200D", "N", "\\u0BB9\\u200D", UIDNA_ERROR_CONTEXTJ },  // no Virama
52127f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u200D", "N", "\\u200D", UIDNA_ERROR_CONTEXTJ },  // no Virama
52227f654740f2a26ad62a5c155af9199af9e69b889claireho    // ZWNJ
52327f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0BB9\\u0BCD\\u200C", "N", "\\u0BB9\\u0BCD\\u200C", 0 },  // Virama+ZWNJ
52427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0BB9\\u200C", "N", "\\u0BB9\\u200C", UIDNA_ERROR_CONTEXTJ },  // no Virama
52527f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u200C", "N", "\\u200C", UIDNA_ERROR_CONTEXTJ },  // no Virama
52627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0644\\u0670\\u200C\\u06ED\\u06EF", "N",  // Joining types D T ZWNJ T R
52727f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0644\\u0670\\u200C\\u06ED\\u06EF", 0 },
52827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0644\\u0670\\u200C\\u06EF", "N",  // D T ZWNJ R
52927f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0644\\u0670\\u200C\\u06EF", 0 },
53027f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0644\\u200C\\u06ED\\u06EF", "N",  // D ZWNJ T R
53127f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0644\\u200C\\u06ED\\u06EF", 0 },
53227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0644\\u200C\\u06EF", "N",  // D ZWNJ R
53327f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0644\\u200C\\u06EF", 0 },
53427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0644\\u0670\\u200C\\u06ED", "N",  // D T ZWNJ T
53527f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0644\\u0670\\u200C\\u06ED", UIDNA_ERROR_BIDI|UIDNA_ERROR_CONTEXTJ },
53627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u06EF\\u200C\\u06EF", "N",  // R ZWNJ R
53727f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u06EF\\u200C\\u06EF", UIDNA_ERROR_CONTEXTJ },
53827f654740f2a26ad62a5c155af9199af9e69b889claireho    { "\\u0644\\u200C", "N",  // D ZWNJ
53927f654740f2a26ad62a5c155af9199af9e69b889claireho      "\\u0644\\u200C", UIDNA_ERROR_BIDI|UIDNA_ERROR_CONTEXTJ },
54083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "\\u0660\\u0661", "B",  // Arabic-Indic Digits alone
54183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "\\u0660\\u0661", UIDNA_ERROR_BIDI },
54283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "\\u06F0\\u06F1", "B",  // Extended Arabic-Indic Digits alone
54383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "\\u06F0\\u06F1", 0 },
54483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "\\u0660\\u06F1", "B",  // Mixed Arabic-Indic Digits
54583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "\\u0660\\u06F1", UIDNA_ERROR_CONTEXTO_DIGITS|UIDNA_ERROR_BIDI },
54683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    // All of the CONTEXTO "Would otherwise have been DISALLOWED" characters
54783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    // in their correct contexts,
54883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    // then each in incorrect context.
54983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "l\\u00B7l\\u4E00\\u0375\\u03B1\\u05D0\\u05F3\\u05F4\\u30FB", "B",
55083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "l\\u00B7l\\u4E00\\u0375\\u03B1\\u05D0\\u05F3\\u05F4\\u30FB", UIDNA_ERROR_BIDI },
55183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "l\\u00B7", "B",
55283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "l\\u00B7", UIDNA_ERROR_CONTEXTO_PUNCTUATION },
55383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "\\u00B7l", "B",
55483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "\\u00B7l", UIDNA_ERROR_CONTEXTO_PUNCTUATION },
55583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "\\u0375", "B",
55683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "\\u0375", UIDNA_ERROR_CONTEXTO_PUNCTUATION },
55783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "\\u03B1\\u05F3", "B",
55883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "\\u03B1\\u05F3", UIDNA_ERROR_CONTEXTO_PUNCTUATION|UIDNA_ERROR_BIDI },
55983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "\\u05F4", "B",
56083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "\\u05F4", UIDNA_ERROR_CONTEXTO_PUNCTUATION },
56183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    { "l\\u30FB", "B",
56283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius      "l\\u30FB", UIDNA_ERROR_CONTEXTO_PUNCTUATION },
56327f654740f2a26ad62a5c155af9199af9e69b889claireho    // Ticket #8137: UTS #46 toUnicode() fails with non-ASCII labels that turn
56427f654740f2a26ad62a5c155af9199af9e69b889claireho    // into 15 characters (UChars).
56527f654740f2a26ad62a5c155af9199af9e69b889claireho    // The bug was in u_strFromPunycode() which did not write the last character
56627f654740f2a26ad62a5c155af9199af9e69b889claireho    // if it just so fit into the end of the destination buffer.
56727f654740f2a26ad62a5c155af9199af9e69b889claireho    // The UTS #46 code gives a default-capacity UnicodeString as the destination buffer,
56827f654740f2a26ad62a5c155af9199af9e69b889claireho    // and the internal UnicodeString capacity is currently 15 UChars on 64-bit machines
56927f654740f2a26ad62a5c155af9199af9e69b889claireho    // but 13 on 32-bit machines.
57027f654740f2a26ad62a5c155af9199af9e69b889claireho    // Label with 15 UChars, for 64-bit-machine testing:
57127f654740f2a26ad62a5c155af9199af9e69b889claireho    { "aaaaaaaaaaaaa\\u00FCa.de", "B", "aaaaaaaaaaaaa\\u00FCa.de", 0 },
57227f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--aaaaaaaaaaaaaa-ssb.de", "B", "aaaaaaaaaaaaa\\u00FCa.de", 0 },
57327f654740f2a26ad62a5c155af9199af9e69b889claireho    { "abschlu\\u00DFpr\\u00FCfung.de", "N", "abschlu\\u00DFpr\\u00FCfung.de", 0 },
57427f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--abschluprfung-hdb15b.de", "B", "abschlu\\u00DFpr\\u00FCfung.de", 0 },
57527f654740f2a26ad62a5c155af9199af9e69b889claireho    // Label with 13 UChars, for 32-bit-machine testing:
57627f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--aaaaaaaaaaaa-nlb.de", "B", "aaaaaaaaaaa\\u00FCa.de", 0 },
57727f654740f2a26ad62a5c155af9199af9e69b889claireho    { "xn--schluprfung-z6a39a.de", "B", "schlu\\u00DFpr\\u00FCfung.de", 0 },
57827f654740f2a26ad62a5c155af9199af9e69b889claireho    // { "", "B",
57927f654740f2a26ad62a5c155af9199af9e69b889claireho    //   "", 0 },
58027f654740f2a26ad62a5c155af9199af9e69b889claireho};
58127f654740f2a26ad62a5c155af9199af9e69b889claireho
58227f654740f2a26ad62a5c155af9199af9e69b889clairehovoid UTS46Test::TestSomeCases() {
58327f654740f2a26ad62a5c155af9199af9e69b889claireho    IcuTestErrorCode errorCode(*this, "TestSomeCases");
58427f654740f2a26ad62a5c155af9199af9e69b889claireho    char buffer[400], buffer2[400];
58527f654740f2a26ad62a5c155af9199af9e69b889claireho    int32_t i;
58627f654740f2a26ad62a5c155af9199af9e69b889claireho    for(i=0; i<LENGTHOF(testCases); ++i) {
58727f654740f2a26ad62a5c155af9199af9e69b889claireho        const TestCase &testCase=testCases[i];
58827f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString input(ctou(testCase.s));
58927f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString expected(ctou(testCase.u));
59027f654740f2a26ad62a5c155af9199af9e69b889claireho        // ToASCII/ToUnicode, transitional/nontransitional
59127f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString aT, uT, aN, uN;
59227f654740f2a26ad62a5c155af9199af9e69b889claireho        IDNAInfo aTInfo, uTInfo, aNInfo, uNInfo;
59327f654740f2a26ad62a5c155af9199af9e69b889claireho        trans->nameToASCII(input, aT, aTInfo, errorCode);
59427f654740f2a26ad62a5c155af9199af9e69b889claireho        trans->nameToUnicode(input, uT, uTInfo, errorCode);
59527f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->nameToASCII(input, aN, aNInfo, errorCode);
59627f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->nameToUnicode(input, uN, uNInfo, errorCode);
59727f654740f2a26ad62a5c155af9199af9e69b889claireho        if(errorCode.logIfFailureAndReset("first-level processing [%d/%s] %s",
59827f654740f2a26ad62a5c155af9199af9e69b889claireho                                          (int)i, testCase.o, testCase.s)
59927f654740f2a26ad62a5c155af9199af9e69b889claireho        ) {
60027f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
60127f654740f2a26ad62a5c155af9199af9e69b889claireho        }
60227f654740f2a26ad62a5c155af9199af9e69b889claireho        // ToUnicode does not set length errors.
60327f654740f2a26ad62a5c155af9199af9e69b889claireho        uint32_t uniErrors=testCase.errors&~
60427f654740f2a26ad62a5c155af9199af9e69b889claireho            (UIDNA_ERROR_EMPTY_LABEL|
60527f654740f2a26ad62a5c155af9199af9e69b889claireho             UIDNA_ERROR_LABEL_TOO_LONG|
60627f654740f2a26ad62a5c155af9199af9e69b889claireho             UIDNA_ERROR_DOMAIN_NAME_TOO_LONG);
60727f654740f2a26ad62a5c155af9199af9e69b889claireho        char mode=testCase.o[0];
60827f654740f2a26ad62a5c155af9199af9e69b889claireho        if(mode=='B' || mode=='N') {
60927f654740f2a26ad62a5c155af9199af9e69b889claireho            if(uNInfo.getErrors()!=uniErrors) {
61027f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.nameToUnicode([%d] %s) unexpected errors %04lx",
61127f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, (long)uNInfo.getErrors());
61227f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
61327f654740f2a26ad62a5c155af9199af9e69b889claireho            }
61427f654740f2a26ad62a5c155af9199af9e69b889claireho            if(uN!=expected) {
61527f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
61627f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.nameToUnicode([%d] %s) unexpected string %s",
61727f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, buffer);
61827f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
61927f654740f2a26ad62a5c155af9199af9e69b889claireho            }
62027f654740f2a26ad62a5c155af9199af9e69b889claireho            if(aNInfo.getErrors()!=testCase.errors) {
62127f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.nameToASCII([%d] %s) unexpected errors %04lx",
62227f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, (long)aNInfo.getErrors());
62327f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
62427f654740f2a26ad62a5c155af9199af9e69b889claireho            }
62527f654740f2a26ad62a5c155af9199af9e69b889claireho        }
62627f654740f2a26ad62a5c155af9199af9e69b889claireho        if(mode=='B' || mode=='T') {
62727f654740f2a26ad62a5c155af9199af9e69b889claireho            if(uTInfo.getErrors()!=uniErrors) {
62827f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("T.nameToUnicode([%d] %s) unexpected errors %04lx",
62927f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, (long)uTInfo.getErrors());
63027f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
63127f654740f2a26ad62a5c155af9199af9e69b889claireho            }
63227f654740f2a26ad62a5c155af9199af9e69b889claireho            if(uT!=expected) {
63327f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
63427f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("T.nameToUnicode([%d] %s) unexpected string %s",
63527f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, buffer);
63627f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
63727f654740f2a26ad62a5c155af9199af9e69b889claireho            }
63827f654740f2a26ad62a5c155af9199af9e69b889claireho            if(aTInfo.getErrors()!=testCase.errors) {
63927f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("T.nameToASCII([%d] %s) unexpected errors %04lx",
64027f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, (long)aTInfo.getErrors());
64127f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
64227f654740f2a26ad62a5c155af9199af9e69b889claireho            }
64327f654740f2a26ad62a5c155af9199af9e69b889claireho        }
64427f654740f2a26ad62a5c155af9199af9e69b889claireho        // ToASCII is all-ASCII if no severe errors
64527f654740f2a26ad62a5c155af9199af9e69b889claireho        if((aNInfo.getErrors()&severeErrors)==0 && !isASCII(aN)) {
64627f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
64727f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("N.nameToASCII([%d] %s) (errors %04lx) result is not ASCII %s",
64827f654740f2a26ad62a5c155af9199af9e69b889claireho                  (int)i, testCase.s, aNInfo.getErrors(), buffer);
64927f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
65027f654740f2a26ad62a5c155af9199af9e69b889claireho        }
65127f654740f2a26ad62a5c155af9199af9e69b889claireho        if((aTInfo.getErrors()&severeErrors)==0 && !isASCII(aT)) {
65227f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
65327f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("T.nameToASCII([%d] %s) (errors %04lx) result is not ASCII %s",
65427f654740f2a26ad62a5c155af9199af9e69b889claireho                  (int)i, testCase.s, aTInfo.getErrors(), buffer);
65527f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
65627f654740f2a26ad62a5c155af9199af9e69b889claireho        }
65727f654740f2a26ad62a5c155af9199af9e69b889claireho        if(verbose) {
65827f654740f2a26ad62a5c155af9199af9e69b889claireho            char m= mode=='B' ? mode : 'N';
65927f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
66027f654740f2a26ad62a5c155af9199af9e69b889claireho            logln("%c.nameToASCII([%d] %s) (errors %04lx) result string: %s",
66127f654740f2a26ad62a5c155af9199af9e69b889claireho                  m, (int)i, testCase.s, aNInfo.getErrors(), buffer);
66227f654740f2a26ad62a5c155af9199af9e69b889claireho            if(mode!='B') {
66327f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
66427f654740f2a26ad62a5c155af9199af9e69b889claireho                logln("T.nameToASCII([%d] %s) (errors %04lx) result string: %s",
66527f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, aTInfo.getErrors(), buffer);
66627f654740f2a26ad62a5c155af9199af9e69b889claireho            }
66727f654740f2a26ad62a5c155af9199af9e69b889claireho        }
66827f654740f2a26ad62a5c155af9199af9e69b889claireho        // second-level processing
66927f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString aTuN, uTaN, aNuN, uNaN;
67027f654740f2a26ad62a5c155af9199af9e69b889claireho        IDNAInfo aTuNInfo, uTaNInfo, aNuNInfo, uNaNInfo;
67127f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->nameToUnicode(aT, aTuN, aTuNInfo, errorCode);
67227f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->nameToASCII(uT, uTaN, uTaNInfo, errorCode);
67327f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->nameToUnicode(aN, aNuN, aNuNInfo, errorCode);
67427f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->nameToASCII(uN, uNaN, uNaNInfo, errorCode);
67527f654740f2a26ad62a5c155af9199af9e69b889claireho        if(errorCode.logIfFailureAndReset("second-level processing [%d/%s] %s",
67627f654740f2a26ad62a5c155af9199af9e69b889claireho                                          (int)i, testCase.o, testCase.s)
67727f654740f2a26ad62a5c155af9199af9e69b889claireho        ) {
67827f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
67927f654740f2a26ad62a5c155af9199af9e69b889claireho        }
68027f654740f2a26ad62a5c155af9199af9e69b889claireho        if(aN!=uNaN) {
68127f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
68227f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(uNaN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
68327f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("N.nameToASCII([%d] %s)!=N.nameToUnicode().N.nameToASCII() "
68427f654740f2a26ad62a5c155af9199af9e69b889claireho                  "(errors %04lx) %s vs. %s",
68527f654740f2a26ad62a5c155af9199af9e69b889claireho                  (int)i, testCase.s, aNInfo.getErrors(), buffer, buffer2);
68627f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
68727f654740f2a26ad62a5c155af9199af9e69b889claireho        }
68827f654740f2a26ad62a5c155af9199af9e69b889claireho        if(aT!=uTaN) {
68927f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
69027f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(uTaN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
69127f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("T.nameToASCII([%d] %s)!=T.nameToUnicode().N.nameToASCII() "
69227f654740f2a26ad62a5c155af9199af9e69b889claireho                  "(errors %04lx) %s vs. %s",
69327f654740f2a26ad62a5c155af9199af9e69b889claireho                  (int)i, testCase.s, aNInfo.getErrors(), buffer, buffer2);
69427f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
69527f654740f2a26ad62a5c155af9199af9e69b889claireho        }
69627f654740f2a26ad62a5c155af9199af9e69b889claireho        if(uN!=aNuN) {
69727f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
69827f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(aNuN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
69927f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("N.nameToUnicode([%d] %s)!=N.nameToASCII().N.nameToUnicode() "
70027f654740f2a26ad62a5c155af9199af9e69b889claireho                  "(errors %04lx) %s vs. %s",
70127f654740f2a26ad62a5c155af9199af9e69b889claireho                  (int)i, testCase.s, uNInfo.getErrors(), buffer, buffer2);
70227f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
70327f654740f2a26ad62a5c155af9199af9e69b889claireho        }
70427f654740f2a26ad62a5c155af9199af9e69b889claireho        if(uT!=aTuN) {
70527f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
70627f654740f2a26ad62a5c155af9199af9e69b889claireho            prettify(aTuN).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
70727f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("T.nameToUnicode([%d] %s)!=T.nameToASCII().N.nameToUnicode() "
70827f654740f2a26ad62a5c155af9199af9e69b889claireho                  "(errors %04lx) %s vs. %s",
70927f654740f2a26ad62a5c155af9199af9e69b889claireho                  (int)i, testCase.s, uNInfo.getErrors(), buffer, buffer2);
71027f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
71127f654740f2a26ad62a5c155af9199af9e69b889claireho        }
71227f654740f2a26ad62a5c155af9199af9e69b889claireho        // labelToUnicode
71327f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString aTL, uTL, aNL, uNL;
71427f654740f2a26ad62a5c155af9199af9e69b889claireho        IDNAInfo aTLInfo, uTLInfo, aNLInfo, uNLInfo;
71527f654740f2a26ad62a5c155af9199af9e69b889claireho        trans->labelToASCII(input, aTL, aTLInfo, errorCode);
71627f654740f2a26ad62a5c155af9199af9e69b889claireho        trans->labelToUnicode(input, uTL, uTLInfo, errorCode);
71727f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->labelToASCII(input, aNL, aNLInfo, errorCode);
71827f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->labelToUnicode(input, uNL, uNLInfo, errorCode);
71927f654740f2a26ad62a5c155af9199af9e69b889claireho        if(errorCode.logIfFailureAndReset("labelToXYZ processing [%d/%s] %s",
72027f654740f2a26ad62a5c155af9199af9e69b889claireho                                          (int)i, testCase.o, testCase.s)
72127f654740f2a26ad62a5c155af9199af9e69b889claireho        ) {
72227f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
72327f654740f2a26ad62a5c155af9199af9e69b889claireho        }
72427f654740f2a26ad62a5c155af9199af9e69b889claireho        if(aN.indexOf((UChar)0x2e)<0) {
72527f654740f2a26ad62a5c155af9199af9e69b889claireho            if(aN!=aNL || aNInfo.getErrors()!=aNLInfo.getErrors()) {
72627f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(aN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
72727f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(aNL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
72827f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.nameToASCII([%d] %s)!=N.labelToASCII() "
72927f654740f2a26ad62a5c155af9199af9e69b889claireho                      "(errors %04lx vs %04lx) %s vs. %s",
73027f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, aNInfo.getErrors(), aNLInfo.getErrors(), buffer, buffer2);
73127f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
73227f654740f2a26ad62a5c155af9199af9e69b889claireho            }
73327f654740f2a26ad62a5c155af9199af9e69b889claireho        } else {
73427f654740f2a26ad62a5c155af9199af9e69b889claireho            if((aNLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) {
73527f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.labelToASCII([%d] %s) errors %04lx missing UIDNA_ERROR_LABEL_HAS_DOT",
73627f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, (long)aNLInfo.getErrors());
73727f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
73827f654740f2a26ad62a5c155af9199af9e69b889claireho            }
73927f654740f2a26ad62a5c155af9199af9e69b889claireho        }
74027f654740f2a26ad62a5c155af9199af9e69b889claireho        if(aT.indexOf((UChar)0x2e)<0) {
74127f654740f2a26ad62a5c155af9199af9e69b889claireho            if(aT!=aTL || aTInfo.getErrors()!=aTLInfo.getErrors()) {
74227f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(aT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
74327f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(aTL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
74427f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("T.nameToASCII([%d] %s)!=T.labelToASCII() "
74527f654740f2a26ad62a5c155af9199af9e69b889claireho                      "(errors %04lx vs %04lx) %s vs. %s",
74627f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, aTInfo.getErrors(), aTLInfo.getErrors(), buffer, buffer2);
74727f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
74827f654740f2a26ad62a5c155af9199af9e69b889claireho            }
74927f654740f2a26ad62a5c155af9199af9e69b889claireho        } else {
75027f654740f2a26ad62a5c155af9199af9e69b889claireho            if((aTLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) {
75127f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("T.labelToASCII([%d] %s) errors %04lx missing UIDNA_ERROR_LABEL_HAS_DOT",
75227f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, (long)aTLInfo.getErrors());
75327f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
75427f654740f2a26ad62a5c155af9199af9e69b889claireho            }
75527f654740f2a26ad62a5c155af9199af9e69b889claireho        }
75627f654740f2a26ad62a5c155af9199af9e69b889claireho        if(uN.indexOf((UChar)0x2e)<0) {
75727f654740f2a26ad62a5c155af9199af9e69b889claireho            if(uN!=uNL || uNInfo.getErrors()!=uNLInfo.getErrors()) {
75827f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(uN).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
75927f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(uNL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
76027f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.nameToUnicode([%d] %s)!=N.labelToUnicode() "
76127f654740f2a26ad62a5c155af9199af9e69b889claireho                      "(errors %04lx vs %04lx) %s vs. %s",
76227f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, uNInfo.getErrors(), uNLInfo.getErrors(), buffer, buffer2);
76327f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
76427f654740f2a26ad62a5c155af9199af9e69b889claireho            }
76527f654740f2a26ad62a5c155af9199af9e69b889claireho        } else {
76627f654740f2a26ad62a5c155af9199af9e69b889claireho            if((uNLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) {
76727f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.labelToUnicode([%d] %s) errors %04lx missing UIDNA_ERROR_LABEL_HAS_DOT",
76827f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, (long)uNLInfo.getErrors());
76927f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
77027f654740f2a26ad62a5c155af9199af9e69b889claireho            }
77127f654740f2a26ad62a5c155af9199af9e69b889claireho        }
77227f654740f2a26ad62a5c155af9199af9e69b889claireho        if(uT.indexOf((UChar)0x2e)<0) {
77327f654740f2a26ad62a5c155af9199af9e69b889claireho            if(uT!=uTL || uTInfo.getErrors()!=uTLInfo.getErrors()) {
77427f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(uT).extract(0, 0x7fffffff, buffer, LENGTHOF(buffer));
77527f654740f2a26ad62a5c155af9199af9e69b889claireho                prettify(uTL).extract(0, 0x7fffffff, buffer2, LENGTHOF(buffer2));
77627f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("T.nameToUnicode([%d] %s)!=T.labelToUnicode() "
77727f654740f2a26ad62a5c155af9199af9e69b889claireho                      "(errors %04lx vs %04lx) %s vs. %s",
77827f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, uTInfo.getErrors(), uTLInfo.getErrors(), buffer, buffer2);
77927f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
78027f654740f2a26ad62a5c155af9199af9e69b889claireho            }
78127f654740f2a26ad62a5c155af9199af9e69b889claireho        } else {
78227f654740f2a26ad62a5c155af9199af9e69b889claireho            if((uTLInfo.getErrors()&UIDNA_ERROR_LABEL_HAS_DOT)==0) {
78327f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("T.labelToUnicode([%d] %s) errors %04lx missing UIDNA_ERROR_LABEL_HAS_DOT",
78427f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s, (long)uTLInfo.getErrors());
78527f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
78627f654740f2a26ad62a5c155af9199af9e69b889claireho            }
78727f654740f2a26ad62a5c155af9199af9e69b889claireho        }
78827f654740f2a26ad62a5c155af9199af9e69b889claireho        // Differences between transitional and nontransitional processing
78927f654740f2a26ad62a5c155af9199af9e69b889claireho        if(mode=='B') {
79027f654740f2a26ad62a5c155af9199af9e69b889claireho            if( aNInfo.isTransitionalDifferent() ||
79127f654740f2a26ad62a5c155af9199af9e69b889claireho                aTInfo.isTransitionalDifferent() ||
79227f654740f2a26ad62a5c155af9199af9e69b889claireho                uNInfo.isTransitionalDifferent() ||
79327f654740f2a26ad62a5c155af9199af9e69b889claireho                uTInfo.isTransitionalDifferent() ||
79427f654740f2a26ad62a5c155af9199af9e69b889claireho                aNLInfo.isTransitionalDifferent() ||
79527f654740f2a26ad62a5c155af9199af9e69b889claireho                aTLInfo.isTransitionalDifferent() ||
79627f654740f2a26ad62a5c155af9199af9e69b889claireho                uNLInfo.isTransitionalDifferent() ||
79727f654740f2a26ad62a5c155af9199af9e69b889claireho                uTLInfo.isTransitionalDifferent()
79827f654740f2a26ad62a5c155af9199af9e69b889claireho            ) {
79927f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("B.process([%d] %s) isTransitionalDifferent()", (int)i, testCase.s);
80027f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
80127f654740f2a26ad62a5c155af9199af9e69b889claireho            }
80227f654740f2a26ad62a5c155af9199af9e69b889claireho            if( aN!=aT || uN!=uT || aNL!=aTL || uNL!=uTL ||
80327f654740f2a26ad62a5c155af9199af9e69b889claireho                aNInfo.getErrors()!=aTInfo.getErrors() || uNInfo.getErrors()!=uTInfo.getErrors() ||
80427f654740f2a26ad62a5c155af9199af9e69b889claireho                aNLInfo.getErrors()!=aTLInfo.getErrors() || uNLInfo.getErrors()!=uTLInfo.getErrors()
80527f654740f2a26ad62a5c155af9199af9e69b889claireho            ) {
80627f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.process([%d] %s) vs. T.process() different errors or result strings",
80727f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s);
80827f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
80927f654740f2a26ad62a5c155af9199af9e69b889claireho            }
81027f654740f2a26ad62a5c155af9199af9e69b889claireho        } else {
81127f654740f2a26ad62a5c155af9199af9e69b889claireho            if( !aNInfo.isTransitionalDifferent() ||
81227f654740f2a26ad62a5c155af9199af9e69b889claireho                !aTInfo.isTransitionalDifferent() ||
81327f654740f2a26ad62a5c155af9199af9e69b889claireho                !uNInfo.isTransitionalDifferent() ||
81427f654740f2a26ad62a5c155af9199af9e69b889claireho                !uTInfo.isTransitionalDifferent() ||
81527f654740f2a26ad62a5c155af9199af9e69b889claireho                !aNLInfo.isTransitionalDifferent() ||
81627f654740f2a26ad62a5c155af9199af9e69b889claireho                !aTLInfo.isTransitionalDifferent() ||
81727f654740f2a26ad62a5c155af9199af9e69b889claireho                !uNLInfo.isTransitionalDifferent() ||
81827f654740f2a26ad62a5c155af9199af9e69b889claireho                !uTLInfo.isTransitionalDifferent()
81927f654740f2a26ad62a5c155af9199af9e69b889claireho            ) {
82027f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("%s.process([%d] %s) !isTransitionalDifferent()",
82127f654740f2a26ad62a5c155af9199af9e69b889claireho                      testCase.o, (int)i, testCase.s);
82227f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
82327f654740f2a26ad62a5c155af9199af9e69b889claireho            }
82427f654740f2a26ad62a5c155af9199af9e69b889claireho            if(aN==aT || uN==uT || aNL==aTL || uNL==uTL) {
82527f654740f2a26ad62a5c155af9199af9e69b889claireho                errln("N.process([%d] %s) vs. T.process() same result strings",
82627f654740f2a26ad62a5c155af9199af9e69b889claireho                      (int)i, testCase.s);
82727f654740f2a26ad62a5c155af9199af9e69b889claireho                continue;
82827f654740f2a26ad62a5c155af9199af9e69b889claireho            }
82927f654740f2a26ad62a5c155af9199af9e69b889claireho        }
83027f654740f2a26ad62a5c155af9199af9e69b889claireho        // UTF-8 if we have std::string
83127f654740f2a26ad62a5c155af9199af9e69b889claireho#if U_HAVE_STD_STRING
83283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius        std::string input8, aT8, uT8, aN8, uN8;
83383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius        StringByteSink<std::string> aT8Sink(&aT8), uT8Sink(&uT8), aN8Sink(&aN8), uN8Sink(&uN8);
83427f654740f2a26ad62a5c155af9199af9e69b889claireho        IDNAInfo aT8Info, uT8Info, aN8Info, uN8Info;
83527f654740f2a26ad62a5c155af9199af9e69b889claireho        input.toUTF8String(input8);
83627f654740f2a26ad62a5c155af9199af9e69b889claireho        trans->nameToASCII_UTF8(input8, aT8Sink, aT8Info, errorCode);
83727f654740f2a26ad62a5c155af9199af9e69b889claireho        trans->nameToUnicodeUTF8(input8, uT8Sink, uT8Info, errorCode);
83827f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->nameToASCII_UTF8(input8, aN8Sink, aN8Info, errorCode);
83927f654740f2a26ad62a5c155af9199af9e69b889claireho        nontrans->nameToUnicodeUTF8(input8, uN8Sink, uN8Info, errorCode);
84027f654740f2a26ad62a5c155af9199af9e69b889claireho        if(errorCode.logIfFailureAndReset("UTF-8 processing [%d/%s] %s",
84127f654740f2a26ad62a5c155af9199af9e69b889claireho                                          (int)i, testCase.o, testCase.s)
84227f654740f2a26ad62a5c155af9199af9e69b889claireho        ) {
84327f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
84427f654740f2a26ad62a5c155af9199af9e69b889claireho        }
84527f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString aT16(UnicodeString::fromUTF8(aT8));
84627f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString uT16(UnicodeString::fromUTF8(uT8));
84727f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString aN16(UnicodeString::fromUTF8(aN8));
84827f654740f2a26ad62a5c155af9199af9e69b889claireho        UnicodeString uN16(UnicodeString::fromUTF8(uN8));
84927f654740f2a26ad62a5c155af9199af9e69b889claireho        if( aN8Info.getErrors()!=aNInfo.getErrors() ||
85027f654740f2a26ad62a5c155af9199af9e69b889claireho            uN8Info.getErrors()!=uNInfo.getErrors()
85127f654740f2a26ad62a5c155af9199af9e69b889claireho        ) {
85227f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("N.xyzUTF8([%d] %s) vs. UTF-16 processing different errors %04lx vs. %04lx",
85327f654740f2a26ad62a5c155af9199af9e69b889claireho                  (int)i, testCase.s,
85427f654740f2a26ad62a5c155af9199af9e69b889claireho                  (long)aN8Info.getErrors(), (long)aNInfo.getErrors());
85527f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
85627f654740f2a26ad62a5c155af9199af9e69b889claireho        }
85727f654740f2a26ad62a5c155af9199af9e69b889claireho        if( aT8Info.getErrors()!=aTInfo.getErrors() ||
85827f654740f2a26ad62a5c155af9199af9e69b889claireho            uT8Info.getErrors()!=uTInfo.getErrors()
85927f654740f2a26ad62a5c155af9199af9e69b889claireho        ) {
86027f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("T.xyzUTF8([%d] %s) vs. UTF-16 processing different errors %04lx vs. %04lx",
86127f654740f2a26ad62a5c155af9199af9e69b889claireho                  (int)i, testCase.s,
86227f654740f2a26ad62a5c155af9199af9e69b889claireho                  (long)aT8Info.getErrors(), (long)aTInfo.getErrors());
86327f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
86427f654740f2a26ad62a5c155af9199af9e69b889claireho        }
86527f654740f2a26ad62a5c155af9199af9e69b889claireho        if(aT16!=aT || uT16!=uT || aN16!=aN || uN16!=uN) {
86627f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("%s.xyzUTF8([%d] %s) vs. UTF-16 processing different string results",
86727f654740f2a26ad62a5c155af9199af9e69b889claireho                  testCase.o, (int)i, testCase.s, (long)aTInfo.getErrors());
86827f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
86927f654740f2a26ad62a5c155af9199af9e69b889claireho        }
87027f654740f2a26ad62a5c155af9199af9e69b889claireho        if( aT8Info.isTransitionalDifferent()!=aTInfo.isTransitionalDifferent() ||
87127f654740f2a26ad62a5c155af9199af9e69b889claireho            uT8Info.isTransitionalDifferent()!=uTInfo.isTransitionalDifferent() ||
87227f654740f2a26ad62a5c155af9199af9e69b889claireho            aN8Info.isTransitionalDifferent()!=aNInfo.isTransitionalDifferent() ||
87327f654740f2a26ad62a5c155af9199af9e69b889claireho            uN8Info.isTransitionalDifferent()!=uNInfo.isTransitionalDifferent()
87427f654740f2a26ad62a5c155af9199af9e69b889claireho        ) {
87527f654740f2a26ad62a5c155af9199af9e69b889claireho            errln("%s.xyzUTF8([%d] %s) vs. UTF-16 processing different isTransitionalDifferent()",
87627f654740f2a26ad62a5c155af9199af9e69b889claireho                  testCase.o, (int)i, testCase.s);
87727f654740f2a26ad62a5c155af9199af9e69b889claireho            continue;
87827f654740f2a26ad62a5c155af9199af9e69b889claireho        }
87927f654740f2a26ad62a5c155af9199af9e69b889claireho#endif
88027f654740f2a26ad62a5c155af9199af9e69b889claireho    }
88127f654740f2a26ad62a5c155af9199af9e69b889claireho}
88227f654740f2a26ad62a5c155af9199af9e69b889claireho
88327f654740f2a26ad62a5c155af9199af9e69b889claireho#endif  // UCONFIG_NO_IDNA
884