Bug 587550 - Fix UnicharSelfTest.cpp, which was busted by deCOMtamination in bug 575043 (rev e0fa43b96c03). r=khuey, a=test-only
authorJustin Lebar <justin.lebar@gmail.com>
Mon, 16 Aug 2010 14:35:39 -0700
changeset 50830 878049d882e62a3dae4ae673b9a0cbba92f49d08
parent 50829 63bb61d1416e49cc1000298eee7650d78d090c1c
child 50831 7ba410f45f4297ff457bcb9cbd28c6b21efcf284
push idunknown
push userunknown
push dateunknown
reviewerskhuey, test-only
bugs587550, 575043
milestone2.0b5pre
Bug 587550 - Fix UnicharSelfTest.cpp, which was busted by deCOMtamination in bug 575043 (rev e0fa43b96c03). r=khuey, a=test-only
intl/unicharutil/tests/Makefile.in
intl/unicharutil/tests/UnicharSelfTest.cpp
--- a/intl/unicharutil/tests/Makefile.in
+++ b/intl/unicharutil/tests/Makefile.in
@@ -49,16 +49,17 @@ XPCSHELL_TESTS	= unit
 CPPSRCS		= UnicharSelfTest.cpp \
 		  NormalizationTest.cpp \
 		  $(NULL)
 
 SIMPLE_PROGRAMS	= $(CPPSRCS:.cpp=$(BIN_SUFFIX))
 
 LIBS		= \
 		$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
+		$(DIST)/lib/$(LIB_PREFIX)unicharutil_external_s.$(LIB_SUFFIX) \
 		$(XPCOM_LIBS) \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= -I$(srcdir)/../public
 
--- a/intl/unicharutil/tests/UnicharSelfTest.cpp
+++ b/intl/unicharutil/tests/UnicharSelfTest.cpp
@@ -47,18 +47,18 @@
 #include "nsIUnicodeEncoder.h"
 #include "nsUnicharUtilCIID.h"
 #include "nsIPersistentProperties2.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsCOMPtr.h"
 #include "nsIUnicodeNormalizer.h"
 #include "nsStringAPI.h"
+#include "nsUnicharUtils.h"
 
-NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
 NS_DEFINE_CID(kEntityConverterCID, NS_ENTITYCONVERTER_CID);
 NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID);
 NS_DEFINE_CID(kUnicodeNormalizerCID, NS_UNICODE_NORMALIZER_CID);
 
 #define TESTLEN 32
 #define T2LEN TESTLEN
 #define T3LEN TESTLEN
 #define T4LEN TESTLEN
@@ -279,114 +279,73 @@ static PRUnichar t4result[T4LEN+2] =  {
   0x2C6E ,  // 30
   0xA640 ,  // 31
   0x0041 ,  // Dummy entry to prevent overflow
   0x00  
 };
 
 void TestCaseConversion()
 {
-   printf("==============================\n");
-   printf("Start nsICaseConversion Test \n");
-   printf("==============================\n");
-   nsICaseConversion *t = NULL;
-   nsresult res;
-   res = CallGetService(kUnicharUtilCID, &t);
-           
-   printf("Test 1 - GetService():\n");
-   if(NS_FAILED(res) || ( t == NULL ) ) {
-     printf("\t1st GetService failed\n");
-   } else {
-     NS_RELEASE(t);
-   }
+  printf("==========================\n");
+  printf("Start case conversion test\n");
+  printf("==========================\n");
 
-   res = CallGetService(kUnicharUtilCID, &t);
-           
-   if(NS_FAILED(res) || ( t == NULL ) ) {
-     printf("\t2nd GetService failed\n");
-   } else {
-     int i;
-     PRUnichar ch;
-     PRUnichar buf[256];
+  int i;
+  PRUnichar buf[256];
 
-    printf("Test 2 - ToUpper(PRUnichar, PRUnichar*):\n");
-    for(i=0;i < T2LEN ; i++)
-    {
-         res = t->ToUpper(t2data[i], &ch);
-         if(NS_FAILED(res)) {
-            printf("\tFailed!! return value != NS_OK\n");
-            break;
-         }
-         if(ch != t2result[i]) 
-            printf("\tFailed!! result unexpected %d\n", i);
-     }
-
-
-    printf("Test 3 - ToLower(PRUnichar, PRUnichar*):\n");
-    for(i=0;i < T3LEN; i++)
-    {
-         res = t->ToLower(t3data[i], &ch);
-         if(NS_FAILED(res)) {
-            printf("\tFailed!! return value != NS_OK\n");
-            break;
-         }
-         if(ch != t3result[i]) 
-            printf("\tFailed!! result unexpected %d\n", i);
-     }
+  printf("Test 2 - ToUpper(PRUnichar, PRUnichar*):\n");
+  for(i=0;i < T2LEN ; i++)
+  {
+    PRUnichar ch = ToUpperCase(t2data[i]);
+    if(ch != t2result[i])
+      printf("\tFailed!! result unexpected %d\n", i);
+  }
 
 
-    printf("Test 4 - ToTitle(PRUnichar, PRUnichar*):\n");
-    for(i=0;i < T4LEN; i++)
-    {
-         res = t->ToTitle(t4data[i], &ch);
-         if(NS_FAILED(res)) {
-            printf("\tFailed!! return value != NS_OK\n");
-            break;
-         }
-         if(ch != t4result[i]) 
-            printf("\tFailed!! result unexpected %d\n", i);
-     }
+  printf("Test 3 - ToLower(PRUnichar, PRUnichar*):\n");
+  for(i=0;i < T3LEN; i++)
+  {
+    PRUnichar ch = ToLowerCase(t3data[i]);
+    if(ch != t3result[i])
+      printf("\tFailed!! result unexpected %d\n", i);
+  }
 
+  printf("Test 4 - ToTitle(PRUnichar, PRUnichar*):\n");
+  for(i=0;i < T4LEN; i++)
+  {
+    PRUnichar ch = ToTitleCase(t4data[i]);
+    if(ch != t4result[i])
+      printf("\tFailed!! result unexpected %d\n", i);
+  }
 
-    printf("Test 5 - ToUpper(PRUnichar*, PRUnichar*, PRUint32):\n");
-    res = t->ToUpper(t2data, buf, T2LEN);
-    if(NS_FAILED(res)) {
-       printf("\tFailed!! return value != NS_OK\n");
-    } else {
-       for(i = 0; i < T2LEN; i++)
-       {
-          if(buf[i] != t2result[i])
-          {
-            printf("\tFailed!! result unexpected %d\n", i);
-            break;
-          }
-       }
-    }
+  printf("Test 5 - ToUpper(PRUnichar*, PRUnichar*, PRUint32):\n");
+  ToUpperCase(t2data, buf, T2LEN);
+  for(i = 0; i < T2LEN; i++)
+  {
+     if(buf[i] != t2result[i])
+     {
+       printf("\tFailed!! result unexpected %d\n", i);
+       break;
+     }
+  }
 
-    printf("Test 6 - ToLower(PRUnichar*, PRUnichar*, PRUint32):\n");
-    res = t->ToLower(t3data, buf, T3LEN);
-    if(NS_FAILED(res)) {
-       printf("\tFailed!! return value != NS_OK\n");
-    } else {
-       for(i = 0; i < T3LEN; i++)
-       {
-          if(buf[i] != t3result[i])
-          {
-            printf("\tFailed!! result unexpected %d\n", i);
-            break;
-          }
-       }
-    }
+  printf("Test 6 - ToLower(PRUnichar*, PRUnichar*, PRUint32):\n");
+  ToLowerCase(t3data, buf, T3LEN);
+  for(i = 0; i < T3LEN; i++)
+  {
+     if(buf[i] != t3result[i])
+     {
+       printf("\tFailed!! result unexpected %d\n", i);
+       break;
+     }
+  }
 
-   NS_RELEASE(t);
-   }
-   printf("==============================\n");
-   printf("Finish nsICaseConversion Test \n");
-   printf("==============================\n");
-
+  printf("===========================\n");
+  printf("Finish case conversion test\n");
+  printf("===========================\n");
 }
 
 static void TestEntityConversion(PRUint32 version)
 {
   printf("==============================\n");
   printf("Start nsIEntityConverter Test \n");
   printf("==============================\n");