]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/msfmrgts.cpp
ICU-8.11.tar.gz
[apple/icu.git] / icuSources / test / intltest / msfmrgts.cpp
index 77229818f042cc299f0b615fb1a0f25fa968cde7..97465a09be7d599bc822510835cde6a40725030f 100644 (file)
@@ -1,8 +1,8 @@
-/********************************************************************
+/***********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2001, International Business Machines Corporation and
- * others. All Rights Reserved.
- ********************************************************************/
+ * Copyright (c) 1997-2005, International Business Machines Corporation
+ * and others. All Rights Reserved.
+ ***********************************************************************/
  
 #include "unicode/utypes.h"
 
@@ -17,6 +17,7 @@
 #include "unicode/numfmt.h"
 #include "unicode/choicfmt.h"
 #include "unicode/gregocal.h"
+#include "putilimp.h"
 
 // *****************************************************************************
 // class MessageFormatRegressionTest
@@ -206,24 +207,33 @@ void MessageFormatRegressionTest::Test4031438()
                 temp = obj.getString(temp);
             else {
                 fmt = NumberFormat::createInstance(status);
-                fmt->format(obj.getType() == Formattable::kLong ? obj.getLong() : obj.getDouble(), temp);
+                switch (obj.getType()) {
+                case Formattable::kLong: fmt->format(obj.getLong(), temp); break;
+                case Formattable::kInt64: fmt->format(obj.getInt64(), temp); break;
+                case Formattable::kDouble: fmt->format(obj.getDouble(), temp); break;
+                default: break;
+                }
             }
 
             // convert to string if not already
             Formattable obj1 = params[i];
             temp1.remove();
-            if(obj1.getType() == Formattable::kDouble || obj1.getType() == Formattable::kLong) {
+            if(obj1.getType() == Formattable::kString)
+                temp1 = obj1.getString(temp1);
+            else {
                 fmt = NumberFormat::createInstance(status);
-                fmt->format(obj1.getType() == Formattable::kLong ? obj1.getLong() : obj1.getDouble(), temp1);
+                switch (obj1.getType()) {
+                case Formattable::kLong: fmt->format(obj1.getLong(), temp1); break;
+                case Formattable::kInt64: fmt->format(obj1.getInt64(), temp1); break;
+                case Formattable::kDouble: fmt->format(obj1.getDouble(), temp1); break;
+                default: break;
+                }
             }
-            else
-                temp1 = obj1.getString(temp1);
 
             //if (objs[i] != NULL && objs[i].getString(temp1) != params[i].getString(temp2)) {
             if (temp != temp1) {
                 errln("Parse failed on object " + objs[i].getString(temp1) + " at index : " + i);
-            }
-        
+            }       
         }
 
         delete fmt;
@@ -747,8 +757,12 @@ void MessageFormatRegressionTest::Test4118594()
     pp.setIndex(0);
     Formattable *newobjs = mf->parse(result, pp, count1);
     // newobjs now equals {new Double(3.1)}
-    if (newobjs[0].getDouble() != 3.1)
-        errln( UnicodeString("newobjs[0] = ") + newobjs[0].getDouble());
+    if (newobjs == NULL) {
+        dataerrln("Error calling MessageFormat::parse");
+    } else {
+        if (newobjs[0].getDouble() != 3.1)
+            errln( UnicodeString("newobjs[0] = ") + newobjs[0].getDouble());
+    }
 
     delete [] objs;
     delete [] newobjs;