]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/testidna.cpp
ICU-511.32.tar.gz
[apple/icu.git] / icuSources / test / intltest / testidna.cpp
index e6d7f78aa8150ea35dbc8590a8555cda20b1c6db..c24dbe6067adf584f3a0ad1bf9cfd6d7944fab10 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003, International Business Machines
+ *   Copyright (C) 2003-2012, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
 
 #if !UCONFIG_NO_IDNA && !UCONFIG_NO_TRANSLITERATION
 
-#include "unicode/uidna.h"
 #include <time.h>
 #include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include "unicode/localpointer.h"
 #include "unicode/ustring.h"
-#include "sprpimpl.h"
-#include "unicode/putil.h"
-#include "cstring.h"
+#include "unicode/usprep.h"
 #include "unicode/uniset.h"
-#include "unicode/ures.h"
-#include "cmemory.h"
 #include "testidna.h"
 #include "idnaref.h"
 #include "nptrans.h"
+#include "unicode/putil.h"
+#include "idnaconf.h"
 
-static UChar unicodeIn[][41] ={
+static const UChar unicodeIn[][41] ={
     { 
         0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643, 0x0644,
         0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A, 0x061F, 0x0000
@@ -146,8 +146,11 @@ static UChar unicodeIn[][41] ={
         0x043e, 0x043d, 0x0438, 0x043d, 0x0435, 0x0433, 0x043e, 0x0432,
         0x043e, 0x0440, 0x044f, 0x0442, 0x043f, 0x043e, 0x0440, 0x0443,
         0x0441, 0x0441, 0x043a, 0x0438
+    },
+    {
+        0xFB00, 0xFB01
     }
-   
+
 };
 
 static const char *asciiIn[] = {
@@ -174,7 +177,7 @@ static const char *asciiIn[] = {
     "xn--hxargifdar",                       // Greek
     "xn--bonusaa-5bb1da",                   // Maltese
     "xn--b1abfaaepdrnnbgefbadotcwatmq2g4l", // Russian (Cyrillic)
-
+    "fffi"
 };
 
 static const char *domainNames[] = {
@@ -209,19 +212,19 @@ static const char *domainNames[] = {
     "pool029.max2.denver.co.dynip.alter.net",
     "cust49.max9.new-york.ny.ms.uu.net",
     "s61.abq-dialin2.hollyberry.com",
-    "http://\\u0917\\u0928\\u0947\\u0936.sanjose.ibm.com",
+    "\\u0917\\u0928\\u0947\\u0936.sanjose.ibm.com", //':'(0x003a) produces U_IDNA_STD3_ASCII_RULES_ERROR
     "www.xn--vea.com",
-    "www.\\u00E0\\u00B3\\u00AF.com",
+   // "www.\\u00E0\\u00B3\\u00AF.com",//' ' (0x0020) produces U_IDNA_STD3_ASCII_RULES_ERROR
     "www.\\u00C2\\u00A4.com",
     "www.\\u00C2\\u00A3.com",
-    "\\u0025",
-    "\\u005C\\u005C",
-    "@",
-    "\\u002F",
-    "www.\\u0021.com",
-    "www.\\u0024.com",
-    "\\u003f",
-    // These yeild U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
+    // "\\u0025", //'%' (0x0025) produces U_IDNA_STD3_ASCII_RULES_ERROR
+    // "\\u005C\\u005C", //'\' (0x005C) produces U_IDNA_STD3_ASCII_RULES_ERROR
+    //"@",
+    //"\\u002F",
+    //"www.\\u0021.com",
+    //"www.\\u0024.com",
+    //"\\u003f",
+    // These yeild U_IDNA_PROHIBITED_ERROR
     //"\\u00CF\\u0082.com",
     //"\\u00CE\\u00B2\\u00C3\\u009Fss.com",
     //"\\u00E2\\u0098\\u00BA.com",
@@ -231,7 +234,7 @@ static const char *domainNames[] = {
 
 typedef struct ErrorCases ErrorCases;
 
-static struct ErrorCases{
+static const struct ErrorCases{
 
     UChar unicode[100];
     const char *ascii;
@@ -245,14 +248,14 @@ static struct ErrorCases{
         { 
             0x0077, 0x0077, 0x0077, 0x002e, /* www. */
             0xC138, 0xACC4, 0xC758, 0xBAA8, 0xB4E0, 0xC0AC, 0xB78C, 0xB4E4, 0xC774,
-            0x2060,/*prohibited*/
+            0x070F,/*prohibited*/
             0xD55C, 0xAD6D, 0xC5B4, 0xB97C, 0xC774, 0xD574, 0xD55C, 0xB2E4, 0xBA74,
             0x002e, 0x0063, 0x006f, 0x006d, /* com. */
             0x0000
         },
-        "www.XN--fxG2146CsoA28OruCyA378BqrE2tCwOp06C5qBw82A1rFfmAE0361DeA96B.com",
-        U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR,
-        FALSE, TRUE, TRUE
+        "www.XN--8mb5595fsoa28orucya378bqre2tcwop06c5qbw82a1rffmae0361dea96b.com",
+        U_IDNA_PROHIBITED_ERROR,
+        FALSE, FALSE, TRUE
     },
 
     {
@@ -265,8 +268,8 @@ static struct ErrorCases{
         },
         "www.XN--6lA2Bz548Fj1GuA391Bf1Gb1N59Ab29A7iA.com",
 
-        U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR,
-        FALSE, TRUE, TRUE
+        U_IDNA_UNASSIGNED_ERROR,
+        FALSE, FALSE, TRUE
     },
     {
         { 
@@ -279,7 +282,7 @@ static struct ErrorCases{
         },
         "www.xn--ghBGI4851OiyA33VqrD6Az86C4qF83CtRv93D5xBk15AzfG0nAgA0578DeA71C.com",
         U_IDNA_CHECK_BIDI_ERROR,
-        FALSE, TRUE, TRUE
+        FALSE, FALSE, TRUE
     },
     {
         { 
@@ -294,7 +297,7 @@ static struct ErrorCases{
         },
         "www.xn----b95Ew8SqA315Ao5FbuMlnNmhA.com",
         U_IDNA_STD3_ASCII_RULES_ERROR,
-        TRUE, TRUE, FALSE
+        TRUE, FALSE, FALSE
     },
     {
         { 
@@ -326,7 +329,7 @@ static struct ErrorCases{
       },
       "www.xn--989AoMsVi5E83Db1D2A355Cv1E0vAk1DwRv93D5xBh15A0Dt30A5JpSD879Ccm6FeA98C.com",
       U_IDNA_LABEL_TOO_LONG_ERROR,
-      FALSE, TRUE, TRUE
+      FALSE, FALSE, TRUE
     },  
     
     { 
@@ -338,7 +341,7 @@ static struct ErrorCases{
       },
       "www.xn--01-tvdmo.com",
       U_IDNA_CHECK_BIDI_ERROR,
-      FALSE, TRUE, TRUE
+      FALSE, FALSE, TRUE
     },  
     
     { 
@@ -349,8 +352,8 @@ static struct ErrorCases{
         0x0000
       },
       "www.XN--ghbgi278xia.com",
-      U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR,
-      FALSE, TRUE, TRUE
+      U_IDNA_PROHIBITED_ERROR,
+      FALSE, FALSE, TRUE
     },
     { 
       {
@@ -361,7 +364,7 @@ static struct ErrorCases{
       },
       "www.-abcde.com",
       U_IDNA_STD3_ASCII_RULES_ERROR,
-      TRUE, TRUE, FALSE
+      TRUE, FALSE, FALSE
     },
     { 
       {
@@ -372,7 +375,7 @@ static struct ErrorCases{
       },
       "www.abcde-.com",
       U_IDNA_STD3_ASCII_RULES_ERROR,
-      TRUE, TRUE, FALSE
+      TRUE, FALSE, FALSE
     },
     { 
       {
@@ -383,7 +386,18 @@ static struct ErrorCases{
       },
       "www.abcde@.com",
       U_IDNA_STD3_ASCII_RULES_ERROR,
-      TRUE, TRUE, FALSE
+      TRUE, FALSE, FALSE
+    },
+    { 
+      {
+        0x0077, 0x0077, 0x0077, 0x002e, // www. 
+        // zero length label
+        0x002e, 0x0063, 0x006f, 0x006d, // com. 
+        0x0000
+      },
+      "www..com",
+      U_IDNA_ZERO_LENGTH_LABEL_ERROR,
+      TRUE, FALSE, FALSE
     },
     { 
       {0},
@@ -394,202 +408,48 @@ static struct ErrorCases{
 };
 
 
-static struct ConformanceTestCases
-   {
-     const char *comment;
-     const char *in;
-     const char *out;
-     const char *profile;
-     int32_t flags;
-     UErrorCode expectedStatus;
-   }
-   conformanceTestCases[] =
-   {
-  
-     {
-       "Case folding ASCII U+0043 U+0041 U+0046 U+0045",
-       "\x43\x41\x46\x45", "\x63\x61\x66\x65",
-       "Nameprep", UIDNA_DEFAULT, 
-       U_ZERO_ERROR
-
-     },
-     {
-       "Case folding 8bit U+00DF (german sharp s)",
-       "\xC3\x9F", "\x73\x73", 
-       "Nameprep", UIDNA_DEFAULT, 
-       U_ZERO_ERROR  
-     },
-     {
-       "Non-ASCII multibyte space character U+1680",
-       "\xE1\x9A\x80", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Non-ASCII 8bit control character U+0085",
-       "\xC2\x85", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Non-ASCII multibyte control character U+180E",
-       "\xE1\xA0\x8E", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Non-ASCII control character U+1D175",
-       "\xF0\x9D\x85\xB5", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Plane 0 private use character U+F123",
-       "\xEF\x84\xA3", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Plane 15 private use character U+F1234",
-       "\xF3\xB1\x88\xB4", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Plane 16 private use character U+10F234",
-       "\xF4\x8F\x88\xB4", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Non-character code point U+8FFFE",
-       "\xF2\x8F\xBF\xBE", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Non-character code point U+10FFFF",
-       "\xF4\x8F\xBF\xBF", NULL,
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR 
-     },
- /* 
-     {
-       "Surrogate code U+DF42",
-       "\xED\xBD\x82", NULL, "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-*/
-     {
-       "Non-plain text character U+FFFD",
-       "\xEF\xBF\xBD", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Ideographic description character U+2FF5",
-       "\xE2\xBF\xB5", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Display property character U+0341",
-       "\xCD\x81", "\xCD\x81",
-       "Nameprep", UIDNA_DEFAULT, U_ZERO_ERROR
-
-     },
-
-     {
-       "Left-to-right mark U+200E",
-       "\xE2\x80\x8E", "\xCC\x81", 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-
-       "Deprecated U+202A",
-       "\xE2\x80\xAA", "\xCC\x81", 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Language tagging character U+E0001",
-       "\xF3\xA0\x80\x81", "\xCC\x81", 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Language tagging character U+E0042",
-       "\xF3\xA0\x81\x82", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_PROHIBITED_CODEPOINT_FOUND_ERROR
-     },
-     {
-       "Bidi: RandALCat character U+05BE and LCat characters",
-       "\x66\x6F\x6F\xD6\xBE\x62\x61\x72", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_CHECK_BIDI_ERROR
-     },
-     {
-       "Bidi: RandALCat character U+FD50 and LCat characters",
-       "\x66\x6F\x6F\xEF\xB5\x90\x62\x61\x72", NULL,
-       "Nameprep",UIDNA_DEFAULT ,
-       U_IDNA_CHECK_BIDI_ERROR
-     },
-     {
-       "Bidi: RandALCat character U+FB38 and LCat characters",
-       "\x66\x6F\x6F\xEF\xB9\xB6\x62\x61\x72", "\x66\x6F\x6F \xd9\x8e\x62\x61\x72",
-       "Nameprep", UIDNA_DEFAULT,
-       U_ZERO_ERROR
-     },
-     { "Bidi: RandALCat without trailing RandALCat U+0627 U+0031",
-       "\xD8\xA7\x31", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_CHECK_BIDI_ERROR
-     },
-     {
-       "Bidi: RandALCat character U+0627 U+0031 U+0628",
-       "\xD8\xA7\x31\xD8\xA8", "\xD8\xA7\x31\xD8\xA8",
-       "Nameprep", UIDNA_DEFAULT,
-       U_ZERO_ERROR
-     },
-     {
-       "Unassigned code point U+E0002",
-       "\xF3\xA0\x80\x82", NULL, 
-       "Nameprep", UIDNA_DEFAULT,
-       U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR
-     },
-
-/*  // Invalid UTF-8
-     {
-       "Larger test (shrinking)",
-       "X\xC2\xAD\xC3\xDF\xC4\xB0\xE2\x84\xA1\x6a\xcc\x8c\xc2\xa0\xc2"
-       "\xaa\xce\xb0\xe2\x80\x80", "xssi\xcc\x87""tel\xc7\xb0 a\xce\xb0 ",
-       "Nameprep",
-       UIDNA_DEFAULT, U_ZERO_ERROR
-     },
-    {
 
-       "Larger test (expanding)",
-       "X\xC3\xDF\xe3\x8c\x96\xC4\xB0\xE2\x84\xA1\xE2\x92\x9F\xE3\x8c\x80",
-       "xss\xe3\x82\xad\xe3\x83\xad\xe3\x83\xa1\xe3\x83\xbc\xe3\x83\x88"
-       "\xe3\x83\xab""i\xcc\x87""tel\x28""d\x29\xe3\x82\xa2\xe3\x83\x91"
-       "\xe3\x83\xbc\xe3\x83\x88"
-       "Nameprep",
-       UIDNA_DEFAULT, U_ZERO_ERROR
-     },
-  */
-};
 
+#define MAX_DEST_SIZE 300
 
+void TestIDNA::debug(const UChar* src, int32_t srcLength, int32_t options){
+    UParseError parseError;
+    UErrorCode transStatus = U_ZERO_ERROR;
+    UErrorCode prepStatus  = U_ZERO_ERROR;
+    NamePrepTransform* trans = NamePrepTransform::createInstance(parseError,transStatus);
+    int32_t prepOptions = (((options & UIDNA_ALLOW_UNASSIGNED) != 0) ? USPREP_ALLOW_UNASSIGNED: 0);
+    LocalUStringPrepProfilePointer prep(usprep_openByType(USPREP_RFC3491_NAMEPREP,&prepStatus));
+    UChar *transOut=NULL, *prepOut=NULL;
+    int32_t transOutLength=0, prepOutLength=0;
+    
+    
+    transOutLength  = trans->process(src,srcLength,transOut, 0, prepOptions>0, &parseError, transStatus);
+    if( transStatus == U_BUFFER_OVERFLOW_ERROR){
+        transStatus = U_ZERO_ERROR;
+        transOut    = (UChar*) malloc(U_SIZEOF_UCHAR * transOutLength);
+        transOutLength = trans->process(src,srcLength,transOut, transOutLength, prepOptions>0, &parseError, transStatus);
+    }
 
-#define MAX_DEST_SIZE 300
+    prepOutLength  = usprep_prepare(prep.getAlias(), src, srcLength, prepOut, 0, prepOptions, &parseError, &prepStatus);
 
+    if( prepStatus == U_BUFFER_OVERFLOW_ERROR){
+        prepStatus = U_ZERO_ERROR;
+        prepOut    = (UChar*) malloc(U_SIZEOF_UCHAR * prepOutLength);
+        prepOutLength  = usprep_prepare(prep.getAlias(), src, srcLength, prepOut, prepOutLength, prepOptions, &parseError, &prepStatus);
+    }
 
+    if(UnicodeString(transOut,transOutLength)!= UnicodeString(prepOut, prepOutLength)){
+        errln("Failed. Expected: " + prettify(UnicodeString(transOut, transOutLength))
+              + " Got: " + prettify(UnicodeString(prepOut,prepOutLength)));
+    }
+    free(transOut);
+    free(prepOut);
+    delete trans;
+}
 
 void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* testName, 
             UBool useSTD3ASCIIRules,UErrorCode expectedStatus,
-            UBool doCompare, UBool testUnassigned,  TestFunc func){
+            UBool doCompare, UBool testUnassigned, TestFunc func, UBool testSTD3ASCIIRules){
 
     UErrorCode status = U_ZERO_ERROR;
     UChar destStack[MAX_DEST_SIZE];
@@ -603,107 +463,131 @@ void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* test
 
     if(src != NULL){
         tSrcLen = u_strlen(src);
-        tSrc  =(UChar*) uprv_malloc( U_SIZEOF_UCHAR * tSrcLen );
-        uprv_memcpy(tSrc,src,tSrcLen * U_SIZEOF_UCHAR);
+        tSrc  =(UChar*) malloc( U_SIZEOF_UCHAR * tSrcLen );
+        memcpy(tSrc,src,tSrcLen * U_SIZEOF_UCHAR);
     }
 
     // test null-terminated source and return value of number of UChars required
-    if( expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR ){
-        destLen = func(src,-1,dest,0,options, &parseError , &status);
+    destLen = func(src,-1,NULL,0,options, &parseError , &status);
+    if(status == U_BUFFER_OVERFLOW_ERROR){
+        status = U_ZERO_ERROR; // reset error code
+        if(destLen+1 < MAX_DEST_SIZE){
+            dest = destStack;
+            destLen = func(src,-1,dest,destLen+1,options, &parseError, &status);
+            // TODO : compare output with expected
+            if(U_SUCCESS(status) && expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR&& (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
+                errln("Did not get the expected result for "+UnicodeString(testName) +" null terminated source. Expected : " 
+                       + prettify(UnicodeString(expected,expectedLen))
+                       + " Got: " + prettify(UnicodeString(dest,destLen))
+                    );
+            }
+        }else{
+            errln( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
+        }
+    }
+
+    if(status != expectedStatus){
+        errcheckln(status, "Did not get the expected error for "+
+                UnicodeString(testName)+
+                " null terminated source. Expected: " +UnicodeString(u_errorName(expectedStatus))
+                + " Got: "+ UnicodeString(u_errorName(status))
+                + " Source: " + prettify(UnicodeString(src))
+               );
+        free(tSrc);
+        return;
+    } 
+    if(testUnassigned ){
+        status = U_ZERO_ERROR;
+        destLen = func(src,-1,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
         if(status == U_BUFFER_OVERFLOW_ERROR){
             status = U_ZERO_ERROR; // reset error code
             if(destLen+1 < MAX_DEST_SIZE){
                 dest = destStack;
-                destLen = func(src,-1,dest,destLen+1,options, &parseError, &status);
+                destLen = func(src,-1,dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
                 // TODO : compare output with expected
-                if(U_SUCCESS(status) && expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR&& (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
-                    errln("Did not get the expected result for "+UnicodeString(testName) +" null terminated source. Expected : " 
-                           + prettify(UnicodeString(expected,expectedLen))
-                           + " Got: " + prettify(UnicodeString(dest,destLen))
-                        );
+                if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
+                    //errln("Did not get the expected result for %s null terminated source with both options set.\n",testName);
+                    errln("Did not get the expected result for "+UnicodeString(testName) +
+                          " null terminated source "+ prettify(src) + 
+                          " with both options set. Expected: "+  prettify(UnicodeString(expected,expectedLen))+
+                          "Got: " + prettify(UnicodeString(dest,destLen)));
+
+                    debug(src,-1,options | UIDNA_ALLOW_UNASSIGNED);
+            
                 }
             }else{
                 errln( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
             }
         }
+        //testing query string
+        if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
+                errln( "Did not get the expected error for "+
+                    UnicodeString(testName)+
+                    " null terminated source with options set. Expected: " +UnicodeString(u_errorName(expectedStatus))
+                    + " Got: "+ UnicodeString(u_errorName(status))
+                    + " Source: " + prettify(UnicodeString(src))
+                   );
+        }  
+    }
 
-        if(status != expectedStatus){
-            errln( "Did not get the expected error for %s null terminated source failed. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
-            uprv_free(tSrc);
-            return;
-        } 
-        if(testUnassigned ){
-            status = U_ZERO_ERROR;
-            destLen = func(src,-1,dest,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
-            if(status == U_BUFFER_OVERFLOW_ERROR){
-                status = U_ZERO_ERROR; // reset error code
-                if(destLen+1 < MAX_DEST_SIZE){
-                    dest = destStack;
-                    destLen = func(src,-1,dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
-                    // TODO : compare output with expected
-                    if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
-                        //errln("Did not get the expected result for %s null terminated source with both options set.\n",testName);
-                        errln("Did not get the expected result for "+UnicodeString(testName) +" null terminated source with both options set. Expected: "+ prettify(UnicodeString(expected,expectedLen)));
-                
-                    }
-                }else{
-                    errln( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
-                }
+    status = U_ZERO_ERROR;
+
+    // test source with lengthand return value of number of UChars required
+    destLen = func(tSrc, tSrcLen, NULL,0,options, &parseError, &status);
+    if(status == U_BUFFER_OVERFLOW_ERROR){
+        status = U_ZERO_ERROR; // reset error code
+        if(destLen+1 < MAX_DEST_SIZE){
+            dest = destStack;
+            destLen = func(src,u_strlen(src),dest,destLen+1,options, &parseError, &status);
+            // TODO : compare output with expected
+            if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
+                errln("Did not get the expected result for %s with source length.\n",testName);
             }
-            //testing query string
-            if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR){
-                errln( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
-            }  
+        }else{
+            errln( "%s with source length  failed. Requires destCapacity > 300\n",testName);
         }
+    }
 
+    if(status != expectedStatus){
+        errln( "Did not get the expected error for "+
+                    UnicodeString(testName)+
+                    " with source length. Expected: " +UnicodeString(u_errorName(expectedStatus))
+                    + " Got: "+ UnicodeString(u_errorName(status))
+                    + " Source: " + prettify(UnicodeString(src))
+                   );
+    } 
+    if(testUnassigned){
         status = U_ZERO_ERROR;
 
-        // test source with lengthand return value of number of UChars required
-        destLen = func(tSrc, tSrcLen, dest,0,options, &parseError, &status);
+        destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
+
         if(status == U_BUFFER_OVERFLOW_ERROR){
             status = U_ZERO_ERROR; // reset error code
             if(destLen+1 < MAX_DEST_SIZE){
                 dest = destStack;
-                destLen = func(src,u_strlen(src),dest,destLen+1,options, &parseError, &status);
+                destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
                 // TODO : compare output with expected
                 if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
-                    errln("Did not get the expected result for %s with source length.\n",testName);
+                    errln("Did not get the expected result for %s with source length and both options set.\n",testName);
                 }
             }else{
                 errln( "%s with source length  failed. Requires destCapacity > 300\n",testName);
             }
         }
-
-        if(status != expectedStatus){
-            errln( "Did not get the expected error for %s with source length. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
-        } 
-        if(testUnassigned){
-            status = U_ZERO_ERROR;
-
-            destLen = func(tSrc,tSrcLen,dest,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
-
-            if(status == U_BUFFER_OVERFLOW_ERROR){
-                status = U_ZERO_ERROR; // reset error code
-                if(destLen+1 < MAX_DEST_SIZE){
-                    dest = destStack;
-                    destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
-                    // TODO : compare output with expected
-                    if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
-                        errln("Did not get the expected result for %s with source length and both options set.\n",testName);
-                    }
-                }else{
-                    errln( "%s with source length  failed. Requires destCapacity > 300\n",testName);
-                }
-            }
-            //testing query string
-            if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR){
-                errln( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
-            }
+        //testing query string
+        if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
+            errln( "Did not get the expected error for "+
+                    UnicodeString(testName)+
+                    " with source length and options set. Expected: " +UnicodeString(u_errorName(expectedStatus))
+                    + " Got: "+ UnicodeString(u_errorName(status))
+                    + " Source: " + prettify(UnicodeString(src))
+                   );
         }
-    }else{
+    }
 
-        status = U_ZERO_ERROR;
-        destLen = func(src,-1,dest,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
+    status = U_ZERO_ERROR;
+    if(testSTD3ASCIIRules==TRUE){
+        destLen = func(src,-1,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
         if(status == U_BUFFER_OVERFLOW_ERROR){
             status = U_ZERO_ERROR; // reset error code
             if(destLen+1 < MAX_DEST_SIZE){
@@ -713,7 +597,7 @@ void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* test
                 if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
                     //errln("Did not get the expected result for %s null terminated source with both options set.\n",testName);
                     errln("Did not get the expected result for "+UnicodeString(testName) +" null terminated source with both options set. Expected: "+ prettify(UnicodeString(expected,expectedLen)));
-            
+        
                 }
             }else{
                 errln( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
@@ -721,12 +605,17 @@ void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* test
         }
         //testing query string
         if(status != expectedStatus){
-            errln( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
+            errln( "Did not get the expected error for "+
+                        UnicodeString(testName)+
+                        " null terminated source with options set. Expected: " +UnicodeString(u_errorName(expectedStatus))
+                        + " Got: "+ UnicodeString(u_errorName(status))
+                        + " Source: " + prettify(UnicodeString(src))
+                       );
         } 
 
         status = U_ZERO_ERROR;
 
-        destLen = func(tSrc,tSrcLen,dest,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
+        destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
 
         if(status == U_BUFFER_OVERFLOW_ERROR){
             status = U_ZERO_ERROR; // reset error code
@@ -742,11 +631,16 @@ void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* test
             }
         }
         //testing query string
-        if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR){
-            errln( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
+        if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
+            errln( "Did not get the expected error for "+
+                        UnicodeString(testName)+
+                        " with source length and options set. Expected: " +UnicodeString(u_errorName(expectedStatus))
+                        + " Got: "+ UnicodeString(u_errorName(status))
+                        + " Source: " + prettify(UnicodeString(src))
+                       );
         }
     }
-    uprv_free(tSrc);
+    free(tSrc);
 }
 
 void TestIDNA::testCompare(const UChar* s1, int32_t s1Len,
@@ -761,7 +655,7 @@ void TestIDNA::testCompare(const UChar* s1, int32_t s1Len,
         errln("Did not get the expected result for %s with null termniated strings.\n",testName);
     }
     if(U_FAILURE(status)){
-        errln( "%s null terminated source failed. Error: %s\n", testName,u_errorName(status));
+        errcheckln(status, "%s null terminated source failed. Error: %s", testName,u_errorName(status));
     }
 
     status = U_ZERO_ERROR;
@@ -771,7 +665,7 @@ void TestIDNA::testCompare(const UChar* s1, int32_t s1Len,
         errln("Did not get the expected result for %s with null termniated strings with options set.\n", testName);
     }
     if(U_FAILURE(status)){
-        errln( "%s null terminated source and options set failed. Error: %s\n",testName, u_errorName(status));
+        errcheckln(status, "%s null terminated source and options set failed. Error: %s",testName, u_errorName(status));
     }
     
     status = U_ZERO_ERROR;
@@ -781,7 +675,7 @@ void TestIDNA::testCompare(const UChar* s1, int32_t s1Len,
         errln("Did not get the expected result for %s with string length.\n",testName);
     }
     if(U_FAILURE(status)){
-        errln( "%s with string length. Error: %s\n",testName, u_errorName(status));
+        errcheckln(status, "%s with string length. Error: %s",testName, u_errorName(status));
     }
     
     status = U_ZERO_ERROR;
@@ -791,7 +685,7 @@ void TestIDNA::testCompare(const UChar* s1, int32_t s1Len,
         errln("Did not get the expected result for %s with string length and options set.\n",testName);
     }
     if(U_FAILURE(status)){
-        errln( "%s with string length and options set. Error: %s\n", u_errorName(status), testName);
+        errcheckln(status, "%s with string length and options set. Error: %s", u_errorName(status), testName);
     }
 }
 
@@ -801,7 +695,7 @@ void TestIDNA::testToASCII(const char* testName, TestFunc func){
     UChar buf[MAX_DEST_SIZE];
 
     for(i=0;i< (int32_t)(sizeof(unicodeIn)/sizeof(unicodeIn[0])); i++){
-        u_charsToUChars(asciiIn[i],buf, uprv_strlen(asciiIn[i])+1);
+        u_charsToUChars(asciiIn[i],buf, (int32_t)(strlen(asciiIn[i])+1));
         testAPI(unicodeIn[i], buf,testName, FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
         
     }
@@ -813,7 +707,7 @@ void TestIDNA::testToUnicode(const char* testName, TestFunc func){
     UChar buf[MAX_DEST_SIZE];
     
     for(i=0;i< (int32_t)(sizeof(asciiIn)/sizeof(asciiIn[0])); i++){
-        u_charsToUChars(asciiIn[i],buf, uprv_strlen(asciiIn[i])+1);
+        u_charsToUChars(asciiIn[i],buf, (int32_t)(strlen(asciiIn[i])+1));
         testAPI(buf,unicodeIn[i],testName,FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
     }
 }
@@ -827,11 +721,11 @@ void TestIDNA::testIDNToUnicode(const char* testName, TestFunc func){
     int32_t bufLen = 0;
     UParseError parseError;
     for(i=0;i< (int32_t)(sizeof(domainNames)/sizeof(domainNames[0])); i++){
-        bufLen = uprv_strlen(domainNames[i]);
+        bufLen = (int32_t)strlen(domainNames[i]);
         bufLen = u_unescape(domainNames[i],buf, bufLen+1);
         func(buf,bufLen,expected,MAX_DEST_SIZE, UIDNA_ALLOW_UNASSIGNED, &parseError,&status);
         if(U_FAILURE(status)){
-            errln( "%s failed to convert domainNames[%i].Error: %s \n",testName, i, u_errorName(status));
+            errcheckln(status, "%s failed to convert domainNames[%i].Error: %s",testName, i, u_errorName(status));
             break;
         }
         testAPI(buf,expected,testName,FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
@@ -853,11 +747,11 @@ void TestIDNA::testIDNToASCII(const char* testName, TestFunc func){
     int32_t bufLen = 0;
     UParseError parseError; 
     for(i=0;i< (int32_t)(sizeof(domainNames)/sizeof(domainNames[0])); i++){
-        bufLen = uprv_strlen(domainNames[i]);
+        bufLen = (int32_t)strlen(domainNames[i]);
         bufLen = u_unescape(domainNames[i],buf, bufLen+1);
         func(buf,bufLen,expected,MAX_DEST_SIZE, UIDNA_ALLOW_UNASSIGNED, &parseError,&status);
         if(U_FAILURE(status)){
-            errln( "%s failed to convert domainNames[%i].Error: %s \n",testName,i, u_errorName(status));
+            errcheckln(status, "%s failed to convert domainNames[%i].Error: %s",testName,i, u_errorName(status));
             break;
         }
         testAPI(buf,expected,testName, FALSE,U_ZERO_ERROR, TRUE, TRUE, func);
@@ -899,7 +793,7 @@ void TestIDNA::testCompare(const char* testName, CompareFunc func){
 
     for(i=0;i< (int32_t)(sizeof(unicodeIn)/sizeof(unicodeIn[0])); i++){
 
-        u_charsToUChars(asciiIn[i],buf+4, uprv_strlen(asciiIn[i])+1);
+        u_charsToUChars(asciiIn[i],buf+4, (int32_t)(strlen(asciiIn[i])+1));
         u_strcat(buf,com);
 
         // for every entry in unicodeIn array
@@ -920,18 +814,14 @@ void TestIDNA::testCompare(const char* testName, CompareFunc func){
         // c) compare it with unicodeIn not equivalent
         if(i==0){
             testCompare(src,srcLen,uni1.getBuffer(),uni1.length()-1,testName, func,FALSE);
-            uni1.releaseBuffer();
         }else{
             testCompare(src,srcLen,uni0.getBuffer(),uni0.length()-1,testName, func,FALSE);
-            uni0.releaseBuffer();
         }
         // d) compare it with asciiIn not equivalent
         if(i==0){
             testCompare(src,srcLen,ascii1.getBuffer(),ascii1.length()-1,testName, func,FALSE);
-            ascii1.releaseBuffer();
         }else{
             testCompare(src,srcLen,ascii0.getBuffer(),ascii0.length()-1,testName, func,FALSE);
-            ascii0.releaseBuffer();
         }
 
     }
@@ -1005,9 +895,8 @@ void printPunycodeOutput(){
 }
 #endif
 
-void TestIDNA::testErrorCases(const char* toASCIIName, TestFunc toASCII,
-                    const char* IDNToASCIIName, TestFunc IDNToASCII,
-                    const char* IDNToUnicodeName, TestFunc IDNToUnicode){
+void TestIDNA::testErrorCases(const char* IDNToASCIIName, TestFunc IDNToASCII,
+                              const char* IDNToUnicodeName, TestFunc IDNToUnicode){
     UChar buf[MAX_DEST_SIZE];
     int32_t bufLen=0;
 
@@ -1015,7 +904,7 @@ void TestIDNA::testErrorCases(const char* toASCIIName, TestFunc toASCII,
         ErrorCases errorCase = errorCases[i];
         UChar* src =NULL;
         if(errorCase.ascii != NULL){
-            bufLen =  uprv_strlen(errorCase.ascii);
+            bufLen =  (int32_t)strlen(errorCase.ascii);
             u_charsToUChars(errorCase.ascii,buf, bufLen+1);
         }else{
             bufLen = 1 ;
@@ -1031,8 +920,8 @@ void TestIDNA::testErrorCases(const char* toASCIIName, TestFunc toASCII,
                 errorCase.expected, TRUE, TRUE, IDNToASCII);
         if(errorCase.testLabel ==TRUE){
             testAPI(src,buf,
-                toASCIIName, errorCase.useSTD3ASCIIRules,
-                errorCase.expected, FALSE,TRUE, toASCII);
+                IDNToASCIIName, errorCase.useSTD3ASCIIRules,
+                errorCase.expected, FALSE,TRUE, IDNToASCII);
         }
         if(errorCase.testToUnicode ==TRUE){
             testAPI((src==NULL)? NULL : buf,src,
@@ -1043,7 +932,7 @@ void TestIDNA::testErrorCases(const char* toASCIIName, TestFunc toASCII,
     }
     
 }
-
+/*
 void TestIDNA::testConformance(const char* toASCIIName, TestFunc toASCII,
                                const char* IDNToASCIIName, TestFunc IDNToASCII,
                                const char* IDNToUnicodeName, TestFunc IDNToUnicode,
@@ -1054,9 +943,9 @@ void TestIDNA::testConformance(const char* toASCIIName, TestFunc toASCII,
     int32_t expectedLen = 0;
     for(int32_t i=0;i< (int32_t)(sizeof(conformanceTestCases)/sizeof(conformanceTestCases[0]));i++){
         const char* utf8Chars1 = conformanceTestCases[i].in;
-        int32_t utf8Chars1Len = strlen(utf8Chars1);
+        int32_t utf8Chars1Len = (int32_t)strlen(utf8Chars1);
         const char* utf8Chars2 = conformanceTestCases[i].out;
-        int32_t utf8Chars2Len = (utf8Chars2 == NULL) ? 0 : strlen(utf8Chars2);
+        int32_t utf8Chars2Len = (utf8Chars2 == NULL) ? 0 : (int32_t)strlen(utf8Chars2);
 
         UErrorCode status = U_ZERO_ERROR;
         u_strFromUTF8(src,MAX_DEST_SIZE,&srcLen,utf8Chars1,utf8Chars1Len,&status);
@@ -1078,13 +967,13 @@ void TestIDNA::testConformance(const char* toASCIIName, TestFunc toASCII,
                     IDNToASCIIName, FALSE,
                     conformanceTestCases[i].expectedStatus, 
                     TRUE, 
-                    (conformanceTestCases[i].expectedStatus != U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR),
+                    (conformanceTestCases[i].expectedStatus != U_IDNA_UNASSIGNED_ERROR),
                     IDNToASCII);
 
             testAPI(src,expected,
                     toASCIIName, FALSE,
                     conformanceTestCases[i].expectedStatus, TRUE, 
-                    (conformanceTestCases[i].expectedStatus != U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR),
+                    (conformanceTestCases[i].expectedStatus != U_IDNA_UNASSIGNED_ERROR),
                     toASCII);
         }
 
@@ -1098,10 +987,10 @@ void TestIDNA::testConformance(const char* toASCIIName, TestFunc toASCII,
     }
     
 }
-
+*/
 // test and ascertain
 // func(func(func(src))) == func(src)
-void TestIDNA::testChaining(UChar* src,int32_t numIterations,const char* testName,
+void TestIDNA::testChaining(const UChar* src,int32_t numIterations,const char* testName,
                   UBool useSTD3ASCIIRules, UBool caseInsensitive, TestFunc func){
     UChar even[MAX_DEST_SIZE];
     UChar odd[MAX_DEST_SIZE];
@@ -1115,15 +1004,15 @@ void TestIDNA::testChaining(UChar* src,int32_t numIterations,const char* testNam
     // test null-terminated source 
     expectedLen = func(src,-1,expected,MAX_DEST_SIZE, options, &parseError, &status);
     if(U_FAILURE(status)){
-        errln("%s null terminated source failed. Error: %s\n",testName, u_errorName(status));
+        errcheckln(status, "%s null terminated source failed. Error: %s",testName, u_errorName(status));
     }
-    uprv_memcpy(odd,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
-    uprv_memcpy(even,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
+    memcpy(odd,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
+    memcpy(even,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
     for(;i<=numIterations; i++){
         if((i%2) ==0){
             evenLen = func(odd,-1,even,MAX_DEST_SIZE,options, &parseError, &status);
             if(U_FAILURE(status)){
-                errln("%s null terminated source failed\n",testName);
+                errcheckln(status, "%s null terminated source failed - %s",testName, u_errorName(status));
                 break;
             }
         }else{
@@ -1152,15 +1041,15 @@ void TestIDNA::testChaining(UChar* src,int32_t numIterations,const char* testNam
     status = U_ZERO_ERROR;
     expectedLen = func(src,-1,expected,MAX_DEST_SIZE,options|UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
     if(U_FAILURE(status)){
-        errln("%s null terminated source with options set failed. Error: %s\n",testName, u_errorName(status));
+        errcheckln(status, "%s null terminated source with options set failed. Error: %s",testName, u_errorName(status));
     }
-    uprv_memcpy(odd,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
-    uprv_memcpy(even,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
+    memcpy(odd,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
+    memcpy(even,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
     for(;i<=numIterations; i++){
         if((i%2) ==0){
             evenLen = func(odd,-1,even,MAX_DEST_SIZE,options|UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
             if(U_FAILURE(status)){
-                errln("%s null terminated source with options set failed\n",testName);
+                errcheckln(status, "%s null terminated source with options set failed - %s",testName, u_errorName(status));
                 break;
             }
         }else{
@@ -1190,21 +1079,21 @@ void TestIDNA::testChaining(UChar* src,int32_t numIterations,const char* testNam
     status = U_ZERO_ERROR;
     expectedLen = func(src,srcLen,expected,MAX_DEST_SIZE,options, &parseError, &status);
     if(U_FAILURE(status)){
-        errln("%s null terminated source failed. Error: %s\n",testName, u_errorName(status));
+        errcheckln(status, "%s null terminated source failed. Error: %s",testName, u_errorName(status));
     }
-    uprv_memcpy(odd,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
-    uprv_memcpy(even,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
+    memcpy(odd,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
+    memcpy(even,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
     for(;i<=numIterations; i++){
         if((i%2) ==0){
             evenLen = func(odd,oddLen,even,MAX_DEST_SIZE,options, &parseError, &status);
             if(U_FAILURE(status)){
-                errln("%s source with source length failed\n",testName);
+                errcheckln(status, "%s source with source length failed - %s",testName, u_errorName(status));
                 break;
             }
         }else{
             oddLen = func(even,evenLen,odd,MAX_DEST_SIZE,options, &parseError, &status);
             if(U_FAILURE(status)){
-                errln("%s source with source length failed\n",testName);
+                errcheckln(status, "%s source with source length failed - %s",testName, u_errorName(status));
                 break;
             }
         }
@@ -1225,21 +1114,21 @@ void TestIDNA::testChaining(UChar* src,int32_t numIterations,const char* testNam
     status = U_ZERO_ERROR;
     expectedLen = func(src,srcLen,expected,MAX_DEST_SIZE,options|UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
     if(U_FAILURE(status)){
-        errln("%s null terminated source with options set failed. Error: %s\n",testName, u_errorName(status));
+        errcheckln(status, "%s null terminated source with options set failed. Error: %s",testName, u_errorName(status));
     }
-    uprv_memcpy(odd,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
-    uprv_memcpy(even,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
+    memcpy(odd,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
+    memcpy(even,expected,(expectedLen+1) * U_SIZEOF_UCHAR);
     for(;i<=numIterations; i++){
         if((i%2) ==0){
             evenLen = func(odd,oddLen,even,MAX_DEST_SIZE,options|UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
             if(U_FAILURE(status)){
-                errln("%s source with source length and options set failed\n",testName);
+                errcheckln(status, "%s source with source length and options set failed - %s",testName, u_errorName(status));
                 break;
             }
         }else{
             oddLen = func(even,evenLen,odd,MAX_DEST_SIZE,options|UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
             if(U_FAILURE(status)){
-                errln("%s  source with source length and options set failed\n",testName);
+                errcheckln(status, "%s  source with source length and options set failed - %s",testName, u_errorName(status));
                 break;
             }
         }
@@ -1264,7 +1153,7 @@ void TestIDNA::testChaining(const char* toASCIIName, TestFunc toASCII,
     UChar buf[MAX_DEST_SIZE];
     
     for(i=0;i< (int32_t)(sizeof(asciiIn)/sizeof(asciiIn[0])); i++){
-        u_charsToUChars(asciiIn[i],buf, uprv_strlen(asciiIn[i])+1);
+        u_charsToUChars(asciiIn[i],buf, (int32_t)(strlen(asciiIn[i])+1));
         testChaining(buf,5,toUnicodeName, FALSE, FALSE, toUnicode);
     }
     for(i=0;i< (int32_t)(sizeof(unicodeIn)/sizeof(unicodeIn[0])); i++){
@@ -1303,7 +1192,7 @@ void TestIDNA::testRootLabelSeparator(const char* testName, CompareFunc func,
 
     for(i=0;i< (int32_t)(sizeof(unicodeIn)/sizeof(unicodeIn[0])); i++){
 
-        u_charsToUChars(asciiIn[i],buf+4, uprv_strlen(asciiIn[i])+1);
+        u_charsToUChars(asciiIn[i],buf+4, (int32_t)(strlen(asciiIn[i])+1));
         u_strcat(buf,com);
 
         // for every entry in unicodeIn array
@@ -1312,15 +1201,17 @@ void TestIDNA::testRootLabelSeparator(const char* testName, CompareFunc func,
         source.append(unicodeIn[i]);
         source.append(com);
         source.append((UChar)0x0000);
-        // a) compare it with itself
+        
         const UChar* src = source.getBuffer();
         int32_t srcLen = u_strlen(src); //subtract null
-
-        testCompare(src,srcLen,src,srcLen,testName, func,TRUE);
         
         // b) compare it with asciiIn equivalent
         testCompare(src,srcLen,buf,u_strlen(buf),testName, func,TRUE);
         
+        // a) compare it with itself
+        testCompare(src,srcLen,src,srcLen,testName, func,TRUE);
+        
+        
         // IDNToASCII comparison
         testAPI(src,buf,IDNToASCIIName,FALSE,U_ZERO_ERROR,TRUE, TRUE, IDNToASCII);
         // IDNToUnicode comparison
@@ -1329,18 +1220,14 @@ void TestIDNA::testRootLabelSeparator(const char* testName, CompareFunc func,
         // c) compare it with unicodeIn not equivalent
         if(i==0){
             testCompare(src,srcLen,uni1.getBuffer(),uni1.length()-1,testName, func,FALSE);
-            uni1.releaseBuffer();
         }else{
             testCompare(src,srcLen,uni0.getBuffer(),uni0.length()-1,testName, func,FALSE);
-            uni0.releaseBuffer();
         }
         // d) compare it with asciiIn not equivalent
         if(i==0){
             testCompare(src,srcLen,ascii1.getBuffer(),ascii1.length()-1,testName, func,FALSE);
-            ascii1.releaseBuffer();
         }else{
             testCompare(src,srcLen,ascii0.getBuffer(),ascii0.length()-1,testName, func,FALSE);
-            ascii0.releaseBuffer();
         }
     }
 }   
@@ -1349,7 +1236,9 @@ void TestIDNA::testRootLabelSeparator(const char* testName, CompareFunc func,
 // runIndexedTest
 //---------------------------------------------
 
-void TestIDNA::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
+extern IntlTest *createUTS46Test();
+
+void TestIDNA::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par)
 {
     if (exec) logln((UnicodeString)"TestSuite IDNA API ");
     switch (index) {
@@ -1364,9 +1253,30 @@ void TestIDNA::runIndexedTest( int32_t index, UBool exec, const char* &name, cha
         case 7: name = "TestRootLabelSeparator"; if(exec) TestRootLabelSeparator(); break;
         case 8: name = "TestCompareReferenceImpl"; if(exec) TestCompareReferenceImpl(); break;
         case 9: name = "TestDataFile"; if(exec) TestDataFile(); break;
+#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
         case 10: name = "TestRefIDNA"; if(exec) TestRefIDNA(); break;
         case 11: name = "TestIDNAMonkeyTest"; if(exec) TestIDNAMonkeyTest(); break;
-        case 12: name = "TestConformance"; if(exec) TestConformance();break;
+#else
+        case 10: case 11: name = "skip"; break;
+#endif
+        case 12: 
+            {
+                name = "TestConformanceTestVectors";
+                if(exec){
+                    logln("TestSuite IDNA conf----"); logln();
+                    IdnaConfTest test;
+                    callTest(test, par);
+                }
+                break;
+            }
+        case 13:
+            name = "UTS46Test";
+            if (exec) {
+                logln("TestSuite UTS46Test---"); logln();
+                LocalPointer<IntlTest> test(createUTS46Test());
+                callTest(*test, par);
+            }
+            break;
         default: name = ""; break; /*needed to end loop*/
     }
 }
@@ -1386,7 +1296,7 @@ void TestIDNA::TestCompare(){
     testCompare("uidna_compare",uidna_compare);
 }
 void TestIDNA::TestErrorCases(){
-    testErrorCases("uidna_toASCII",uidna_toASCII, "uidna_IDNToASCII",uidna_IDNToASCII,
+    testErrorCases( "uidna_IDNToASCII",uidna_IDNToASCII,
                     "uidna_IDNToUnicode",uidna_IDNToUnicode);
 }
 void TestIDNA::TestRootLabelSeparator(){
@@ -1398,10 +1308,7 @@ void TestIDNA::TestRootLabelSeparator(){
 void TestIDNA::TestChaining(){
     testChaining("uidna_toASCII",uidna_toASCII, "uidna_toUnicode", uidna_toUnicode);
 }
-void TestIDNA::TestConformance(){
-    testConformance("uidna_toASCII",uidna_toASCII,"uidna_IDNToASCII",uidna_IDNToASCII,
-                    "uidna_IDNToUnicode",uidna_IDNToUnicode, "uidna_toUnicode", uidna_toUnicode);
-}
+
 
 static const int loopCount = 100;
 static const int maxCharCount = 20;
@@ -1452,97 +1359,194 @@ void getTestSource(UnicodeString& fillIn) {
     }
        
 }
-void TestIDNA::testCompareReferenceImpl(const UChar* src, int32_t srcLen){
+
+UnicodeString TestIDNA::testCompareReferenceImpl(UnicodeString& src, 
+                                        TestFunc refIDNA, const char* refIDNAName,
+                                        TestFunc uIDNA, const char* uIDNAName,
+                                        int32_t options){
+  
+    const UChar* srcUChars = src.getBuffer();
+    UChar exp[MAX_DEST_SIZE]={0};
+    int32_t expCap = MAX_DEST_SIZE, expLen=0;
+    UErrorCode expStatus = U_ZERO_ERROR;
+    UParseError parseError;
+
+    logln("Comparing "+ UnicodeString(refIDNAName) 
+           + " with "+ UnicodeString(uIDNAName) 
+           +" for input: " + prettify(srcUChars));
     
-    UnicodeString label, idn("www.");
+    expLen = refIDNA(srcUChars, src.length()-1, exp, expCap,
+                      options, &parseError, &expStatus);
+
+    UChar got[MAX_DEST_SIZE]={0};
+    int32_t gotCap = MAX_DEST_SIZE, gotLen=0;
+    UErrorCode gotStatus = U_ZERO_ERROR;
+
+    gotLen = uIDNA(srcUChars, src.length()-1, got, gotCap,
+                   options, &parseError, &gotStatus);
+
+    if(expStatus != gotStatus){
+        errln("Did not get the expected status while comparing " + UnicodeString(refIDNAName)
+               + " with " + UnicodeString(uIDNAName)
+               + " Expected: " + UnicodeString(u_errorName(expStatus))
+               + " Got: " + UnicodeString(u_errorName(gotStatus))
+               + " for Source: "+ prettify(srcUChars) 
+               + " Options: " + options);
+        return UnicodeString("");
+    }
     
-    label.append(src, srcLen);
-    label.append((UChar)0x0000);
-
-    {
-        
-        const UChar* labelUChars = label.getBuffer();
-        UChar ascii[MAX_DEST_SIZE]={0};
-        int32_t asciiCapacity = MAX_DEST_SIZE, asciiLen=0;
-        UChar uni[MAX_DEST_SIZE]={0};
-        int32_t uniCapacity = MAX_DEST_SIZE, uniLen=0;
-        UErrorCode expectedStatus = U_ZERO_ERROR;
-        UParseError parseError;
-        //ascii[0] = uni[0] =0;
-        logln("Comparing idnaref_toASCII with uidna_toASCII for input: " + prettify(label));
-        
-        asciiLen = idnaref_toASCII(labelUChars, label.length()-1,ascii,asciiCapacity,
-                                      UIDNA_DEFAULT,&parseError,&expectedStatus);
-
-        if(expectedStatus == U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR){
-            expectedStatus = U_ZERO_ERROR;
-            asciiLen = idnaref_toASCII(labelUChars, label.length()-1,ascii,asciiCapacity,
-                            UIDNA_ALLOW_UNASSIGNED,&parseError,&expectedStatus);
-            expectedStatus = U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR;
+    // now we know that both implementations yielded same error
+    if(U_SUCCESS(expStatus)){
+        // compare the outputs if status == U_ZERO_ERROR
+        if(u_strCompare(exp, expLen, got, gotLen, TRUE) != 0){
+            errln("Did not get the expected output while comparing " + UnicodeString(refIDNAName)
+               + " with " + UnicodeString(uIDNAName)
+               + " Expected: " + prettify(UnicodeString(exp, expLen))
+               + " Got: " + prettify(UnicodeString(got, gotLen))
+               + " for Source: "+ prettify(srcUChars) 
+               + " Options: " + options);
         }
+        return UnicodeString(exp, expLen);
 
-        testAPI(labelUChars,ascii, "uidna_toASCII",FALSE,
-                expectedStatus,TRUE, TRUE, uidna_toASCII);
-        if(expectedStatus == U_ZERO_ERROR){
-            logln("Comparing idnaref_toUnicode with uidna_toUnicode for input: " + prettify(label));
-            expectedStatus = U_ZERO_ERROR;
-            uniLen = idnaref_toUnicode(ascii, asciiLen, uni,uniCapacity,UIDNA_DEFAULT,
-                                        &parseError,&expectedStatus);
-            if(expectedStatus == U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR){
-                expectedStatus = U_ZERO_ERROR;
-                uniLen = idnaref_toUnicode(ascii, asciiLen, uni,uniCapacity,UIDNA_DEFAULT,
-                                        &parseError,&expectedStatus);
-                expectedStatus = U_IDNA_UNASSIGNED_CODEPOINT_FOUND_ERROR;
-            }
-            testAPI(ascii,uni,"uidna_toUnicode",FALSE,expectedStatus,TRUE, FALSE, uidna_toUnicode);
-        }
+    }else{
+        logln("Got the same error while comparing " 
+            + UnicodeString(refIDNAName) 
+            + " with "+ UnicodeString(uIDNAName) 
+            +" for input: " + prettify(srcUChars));
+    }
+    return UnicodeString("");
+}
+
+void TestIDNA::testCompareReferenceImpl(const UChar* src, int32_t srcLen){
+    UnicodeString label(src,srcLen);
+    label.append((UChar)0x0000);
+
+    //test idnaref_toASCII and idnare
+    UnicodeString asciiLabel = testCompareReferenceImpl(label, 
+                                                      idnaref_toASCII, "idnaref_toASCII",
+                                                      uidna_toASCII, "uidna_toASCII",
+                                                      UIDNA_ALLOW_UNASSIGNED);
+    testCompareReferenceImpl(label, 
+                              idnaref_toASCII, "idnaref_toASCII",
+                              uidna_toASCII, "uidna_toASCII",
+                              UIDNA_DEFAULT);
+    testCompareReferenceImpl(label, 
+                              idnaref_toASCII, "idnaref_toASCII",
+                              uidna_toASCII, "uidna_toASCII",
+                              UIDNA_USE_STD3_RULES);
+    testCompareReferenceImpl(label, 
+                              idnaref_toASCII, "idnaref_toASCII",
+                              uidna_toASCII, "uidna_toASCII",
+                              UIDNA_USE_STD3_RULES | UIDNA_ALLOW_UNASSIGNED);
+
+    if(asciiLabel.length()!=0){
+        asciiLabel.append((UChar)0x0000);
+
+        // test toUnciode
+        testCompareReferenceImpl(asciiLabel, 
+                                  idnaref_toUnicode, "idnaref_toUnicode",
+                                  uidna_toUnicode, "uidna_toUnicode",
+                                  UIDNA_ALLOW_UNASSIGNED);
+        testCompareReferenceImpl(asciiLabel, 
+                                  idnaref_toUnicode, "idnaref_toUnicode",
+                                  uidna_toUnicode, "uidna_toUnicode",
+                                  UIDNA_DEFAULT);
+        testCompareReferenceImpl(asciiLabel, 
+                                  idnaref_toUnicode, "idnaref_toUnicode",
+                                  uidna_toUnicode, "uidna_toUnicode",
+                                  UIDNA_USE_STD3_RULES);
+        testCompareReferenceImpl(asciiLabel, 
+                                  idnaref_toUnicode, "idnaref_toUnicode",
+                                  uidna_toUnicode, "uidna_toUnicode",
+                                  UIDNA_USE_STD3_RULES | UIDNA_ALLOW_UNASSIGNED);
     }
 
 }
+const char* failures[] ={
+    "\\uAA42\\U0001F8DD\\U00019D01\\U000149A3\\uD385\\U000EE0F5\\U00018B92\\U000179D1\\U00018624\\U0002227F\\U000E83C0\\U000E8DCD\\u5460\\U00017F34\\U0001570B\\u43D1\\U0002C9C9\\U000281EC\\u2105\\U000180AE\\uC5D4",
+    "\\U0002F5A6\\uD638\\u0D0A\\u9E9C\\uFE5B\\U0001FCCB\\u66C4",
+};
+
 void TestIDNA::TestIDNAMonkeyTest(){
     UnicodeString source;
     UErrorCode status = U_ZERO_ERROR;
+    int i;
 
     getInstance(status);    // Init prep
-    
-    for(int i=0; i<loopCount; i++){
+    if (U_FAILURE(status)) {
+        dataerrln("Test could not initialize. Got %s", u_errorName(status));
+        return;
+    }
+
+    for(i=0; i<loopCount; i++){
         source.truncate(0);
         getTestSource(source);
         source.append((UChar)0x0000);
-        testCompareReferenceImpl(source.getBuffer(),source.length()-1);
-        source.releaseBuffer();
+        const UChar* src = source.getBuffer();
+        testCompareReferenceImpl(src,source.length()-1);
+        testCompareReferenceImpl(src,source.length()-1);
+    }
+    
+    /* for debugging */
+    for (i=0; i<(int)(sizeof(failures)/sizeof(failures[0])); i++){
+        source.truncate(0);
+        source.append( UnicodeString(failures[i], -1, US_INV) );
+        source = source.unescape();
+        source.append((UChar)0x0000);
+        const UChar *src = source.getBuffer();
+        testCompareReferenceImpl(src,source.length()-1);
+        //debug(source.getBuffer(),source.length(),UIDNA_ALLOW_UNASSIGNED);
     }
-    /* for debugging
-    source.append("\\U000E5BC8\\U00025112\\U00016846\\U0001B375\\U0002EDE4"
-                  "\\U00016E18\\U00010B84\\U000E1639\\U0001C3BE\\u336B\\u5F66"
-                  "\\u2AA6\\uD817\\u0000");
-    source = source.unescape();
-    testCompareReferenceImpl(source.getBuffer(),source.length()-1);
-    source.releaseBuffer();
-    */
-
-    delete TestIDNA::prep;
-    TestIDNA::prep = NULL;
+
+    
+    source.truncate(0);
+    source.append(UNICODE_STRING_SIMPLE("\\uCF18\\U00021161\\U000EEF11\\U0002BB82\\U0001D63C"));
+    debug(source.getBuffer(),source.length(),UIDNA_ALLOW_UNASSIGNED);
+    
+    { // test deletion of code points
+        UnicodeString source("\\u043f\\u00AD\\u034f\\u043e\\u0447\\u0435\\u043c\\u0443\\u0436\\u0435\\u043e\\u043d\\u0438\\u043d\\u0435\\u0433\\u043e\\u0432\\u043e\\u0440\\u044f\\u0442\\u043f\\u043e\\u0440\\u0443\\u0441\\u0441\\u043a\\u0438\\u0000", -1, US_INV);
+        source = source.unescape();
+        UnicodeString expected("\\u043f\\u043e\\u0447\\u0435\\u043c\\u0443\\u0436\\u0435\\u043e\\u043d\\u0438\\u043d\\u0435\\u0433\\u043e\\u0432\\u043e\\u0440\\u044f\\u0442\\u043f\\u043e\\u0440\\u0443\\u0441\\u0441\\u043a\\u0438\\u0000", -1, US_INV);
+        expected = expected.unescape();
+        UnicodeString ascii("xn--b1abfaaepdrnnbgefbadotcwatmq2g4l");
+        ascii.append((UChar)0x0000);
+        testAPI(source.getBuffer(),ascii.getBuffer(), "uidna_toASCII", FALSE, U_ZERO_ERROR, TRUE, TRUE, uidna_toASCII);
+        
+        testAPI(source.getBuffer(),ascii.getBuffer(), "idnaref_toASCII", FALSE, U_ZERO_ERROR, TRUE, TRUE, idnaref_toASCII);
+
+        testCompareReferenceImpl(source.getBuffer(), source.length()-1);
+    }
+
 }
 
 void TestIDNA::TestCompareReferenceImpl(){
-    
+
     UChar src [2] = {0,0};
     int32_t srcLen = 0;
-    
 
-    for(int32_t i = 0x40000 ; i< 0x10ffff; i++){
-        if(quick==TRUE && i> 0x1FFFF){
+    // data even OK?
+    {
+      UErrorCode dataStatus = U_ZERO_ERROR;
+      loadTestData(dataStatus);
+      if(U_FAILURE(dataStatus)) {
+        dataerrln("Couldn't load test data: %s\n", u_errorName(dataStatus)); // save us from thousands and thousands of errors
+        return;
+      }
+    }
+
+    for (int32_t i = 0; i <= 0x10FFFF; i++){
+        if (quick == TRUE && i > 0x0FFF){
             return;
         }
-        if(i >= 0x30000){
-           i+=0xB0000;
+        if(i == 0x30000){
+            // jump to E0000, no characters assigned in plain 3 to plain 13 as of Unicode 6.0
+            i = 0xE0000;
         }
-        if(i>0xFFFF){
-           src[0] = U16_LEAD(i);
-           src[1] = U16_TRAIL(i);
-           srcLen =2;
-        }else{
+        if (i > 0xFFFF){
+            src[0] = U16_LEAD(i);
+            src[1] = U16_TRAIL(i);
+            srcLen =2;
+        } else {
             src[0] = (UChar)i;
             src[1] = 0;
             srcLen = 1;
@@ -1552,12 +1556,21 @@ void TestIDNA::TestCompareReferenceImpl(){
 }
 
 void TestIDNA::TestRefIDNA(){
+    UErrorCode status = U_ZERO_ERROR;
+    getInstance(status);    // Init prep
+    if (U_FAILURE(status)) {
+        if (status == U_FILE_ACCESS_ERROR) {
+            dataerrln("Test could not initialize. Got %s", u_errorName(status));
+        }
+        return;
+    }
+
     testToASCII("idnaref_toASCII", idnaref_toASCII);
     testToUnicode("idnaref_toUnicode", idnaref_toUnicode);
     testIDNToASCII("idnaref_IDNToASCII", idnaref_IDNToASCII);
     testIDNToUnicode("idnaref_IDNToUnicode", idnaref_IDNToUnicode);
     testCompare("idnaref_compare",idnaref_compare);
-    testErrorCases("idnaref_toASCII",idnaref_toASCII, "idnaref_IDNToASCII",idnaref_IDNToASCII,
+    testErrorCases( "idnaref_IDNToASCII",idnaref_IDNToASCII,
                     "idnaref_IDNToUnicode",idnaref_IDNToUnicode);
     testChaining("idnaref_toASCII",idnaref_toASCII, "idnaref_toUnicode", idnaref_toUnicode);
 
@@ -1566,12 +1579,31 @@ void TestIDNA::TestRefIDNA(){
                             "idnaref_IDNToUnicode",idnaref_IDNToUnicode
                             );
     testChaining("idnaref_toASCII",idnaref_toASCII, "idnaref_toUnicode", idnaref_toUnicode);
-    delete TestIDNA::prep;
-    TestIDNA::prep = NULL;
 }
 
+
 void TestIDNA::TestDataFile(){
      testData(*this);
 }
+TestIDNA::~TestIDNA(){
+    if(gPrep!=NULL){
+        delete gPrep;
+        gPrep = NULL;
+    }
+}
 
+NamePrepTransform* TestIDNA::gPrep = NULL;
+
+NamePrepTransform* TestIDNA::getInstance(UErrorCode& status){
+    if(TestIDNA::gPrep == NULL){
+        UParseError parseError;
+        TestIDNA::gPrep = NamePrepTransform::createInstance(parseError, status);
+        if(TestIDNA::gPrep ==NULL){
+           //status = U_MEMORY_ALLOCATION_ERROR;
+           return NULL;
+        }
+    }
+    return TestIDNA::gPrep;
+
+}
 #endif /* #if !UCONFIG_NO_IDNA */