]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/pptest.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / intltest / pptest.cpp
index 954a1bd1d96bce77858087e645f0ce28633d2aba..0f619d0e1c673c166e8162b49e8e91dacbedd76f 100644 (file)
@@ -1,6 +1,8 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2001, International Business Machines Corporation and
+ * Copyright (c) 1997-2010, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -33,10 +35,14 @@ void ParsePositionTest::runIndexedTest( int32_t index, UBool exec, const char* &
 }
 
 UBool 
-ParsePositionTest::failure(UErrorCode status, const char* msg)
+ParsePositionTest::failure(UErrorCode status, const char* msg, UBool possibleDataError)
 {
     if(U_FAILURE(status)) {
-        errln(UnicodeString("FAIL: ") + msg + " failed, error " + u_errorName(status));
+        if (possibleDataError) {
+            dataerrln(UnicodeString("FAIL: ") + msg + " failed, error " + u_errorName(status));
+        } else {
+            errln(UnicodeString("FAIL: ") + msg + " failed, error " + u_errorName(status));
+        }
         return TRUE;
     }
 
@@ -91,6 +97,11 @@ void ParsePositionTest::TestParsePosition()
         errln("*** PP operator= operator== or operator != result");
     }
 
+    ParsePosition *ppp = pp5.clone();
+    if(ppp == &pp5 || *ppp != pp5) {
+        errln("ParsePosition.clone() failed");
+    }
+    delete ppp;
 }
 
 void ParsePositionTest::TestFieldPosition() 
@@ -142,6 +153,12 @@ void ParsePositionTest::TestFieldPosition()
     }
 
     logln("");
+
+    FieldPosition *pfp = fp.clone();
+    if(pfp == &fp || *pfp != fp) {
+        errln("FieldPosition.clone() failed");
+    }
+    delete pfp;
 }
 
 void ParsePositionTest::TestFieldPosition_example() 
@@ -162,13 +179,16 @@ void ParsePositionTest::TestFieldPosition_example()
 
     UErrorCode status = U_ZERO_ERROR;
     NumberFormat *nf = NumberFormat::createInstance(status);
-    failure(status, "NumberFormat::createInstance");
+    if (failure(status, "NumberFormat::createInstance", TRUE)){
+        delete nf;
+        return;
+    }
 
-    if(nf->getDynamicClassID() != DecimalFormat::getStaticClassID()) {
+    DecimalFormat *fmt = dynamic_cast<DecimalFormat *>(nf);
+    if(fmt == NULL) {
         errln("NumberFormat::createInstance returned unexpected class type");
         return;
     }
-    DecimalFormat *fmt = (DecimalFormat*) nf;
     fmt->setDecimalSeparatorAlwaysShown(TRUE);
 
     const int tempLen = 20;