-/********************************************************************
+/***********************************************************************
* 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"
#include "unicode/numfmt.h"
#include "unicode/choicfmt.h"
#include "unicode/gregocal.h"
+#include "putilimp.h"
// *****************************************************************************
// class MessageFormatRegressionTest
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;
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;