harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r378550 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/MessageFormat.java test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
Date Fri, 17 Feb 2006 15:48:15 GMT
Author: tellison
Date: Fri Feb 17 07:48:14 2006
New Revision: 378550

URL: http://svn.apache.org/viewcvs?rev=378550&view=rev
Log:
Fix for HARMONY-63 (java.text.MessageFormat.parse(String): incorrect size of Object array
parsed from the string)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java?rev=378550&r1=378549&r2=378550&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/MessageFormat.java
Fri Feb 17 07:48:14 2006
@@ -532,7 +532,7 @@
 			return new Object[0];
 		ParsePosition internalPos = new ParsePosition(0);
 		int offset = position.getIndex();
-		Object[] result = new Object[10];
+		Object[] result = new Object[maxOffset + 1];
 		for (int i = 0; i <= maxOffset; i++) {
 			String sub = strings[i];
 			if (!string.startsWith(sub, offset)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java?rev=378550&r1=378549&r2=378550&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
Fri Feb 17 07:48:14 2006
@@ -16,13 +16,26 @@
 package org.apache.harmony.tests.java.text;
 
 import java.text.MessageFormat;
+import java.text.ParseException;
+import java.util.Locale;
 
 import junit.framework.TestCase;
 
 public class MessageFormatTest extends TestCase {
 
 	/**
-	 * @tests java.textMessageFormat#toPattern()
+	 * @tests java.text.MessageFormat#parse(java.lang.String)
+	 */
+	public void test_parse() throws ParseException {
+		// Regression for HARMONY-63
+		MessageFormat mf = new MessageFormat("{0,number,#,####}", Locale.US);
+		Object[] res = mf.parse("1,00,00");
+		assertEquals("Assert 0: incorrect size of parsed data ", 1, res.length);
+		assertEquals("Assert 1: parsed value incorrectly", new Long(10000), (Long)res[0]);
+	} 
+    
+	/**
+	 * @tests java.text.MessageFormat#toPattern()
 	 */
 	public void test_toPattern() {
 		// Regression for HARMONY-59



Mime
View raw message