harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r405045 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/org/apache/harmony/luni/util/ test/java/org/apache/harmony/tests/luni/ test/java/org/apache/harmony/tests/luni/util/
Date Mon, 08 May 2006 13:20:45 GMT
Author: gharley
Date: Mon May  8 06:20:43 2006
New Revision: 405045

URL: http://svn.apache.org/viewcvs?rev=405045&view=rev
Log:
HARMONY-391 : Use StringBuilder in MsgHelp.format() and test case

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/AllTests.java
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/MsgHelpTest.java
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/MsgHelp.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/MsgHelp.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/MsgHelp.java?rev=405045&r1=405044&r2=405045&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/MsgHelp.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/MsgHelp.java
Mon May  8 06:20:43 2006
@@ -48,7 +48,7 @@
 	 * @return String the formatted message.
 	 */
 	public static String format(String format, Object[] args) {
-		StringBuffer answer = new StringBuffer(format.length()
+		StringBuilder answer = new StringBuilder(format.length()
 				+ (args.length * 20));
 		String[] argStrings = new String[args.length];
 		for (int i = 0; i < args.length; ++i) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/AllTests.java?rev=405045&r1=405044&r2=405045&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/AllTests.java
Mon May  8 06:20:43 2006
@@ -32,6 +32,7 @@
 		suite.addTest(org.apache.harmony.tests.java.lang.AllTests.suite());
 		suite.addTest(org.apache.harmony.tests.java.net.AllTests.suite());
 		suite.addTest(org.apache.harmony.tests.java.util.AllTests.suite());
+        suite.addTest(org.apache.harmony.tests.luni.util.AllTests.suite());
 		//$JUnit-END$
 		return suite;
 	}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/AllTests.java?rev=405045&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/AllTests.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/AllTests.java
Mon May  8 06:20:43 2006
@@ -0,0 +1,35 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.luni.util;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(AllTests.suite());
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(
+                "Suite for org.apache.harmony.tests.luni.util");
+        //$JUnit-BEGIN$
+        suite.addTestSuite(MsgHelpTest.class);
+        //$JUnit-END$
+        return suite;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/AllTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/MsgHelpTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/MsgHelpTest.java?rev=405045&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/MsgHelpTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/MsgHelpTest.java
Mon May  8 06:20:43 2006
@@ -0,0 +1,72 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.luni.util;
+
+import org.apache.harmony.luni.util.MsgHelp;
+
+import junit.framework.TestCase;
+
+public class MsgHelpTest extends TestCase {
+
+    public MsgHelpTest(String name) {
+        super(name);
+    }
+
+    /*
+     * Test method for 'org.apache.harmony.luni.util.MsgHelp.format(String,
+     * Object[])'
+     */
+    public void testFormatLjava_lang_String$Ljava_lang_Object() {
+        assertEquals("empty", MsgHelp.format("empty", new Object[0]));
+
+        assertEquals("<null>", MsgHelp.format("{0}", new Object[1]));
+        assertEquals("<missing argument>", MsgHelp.format("{0}", new Object[0]));
+        assertEquals("fixture {} fixture", MsgHelp.format("{0} \\{} {0}",
+                new Object[] { "fixture" }));
+
+        assertEquals("<null> fixture", MsgHelp.format("{0} {1}", new Object[] {
+                null, "fixture" }));
+        assertEquals("<null> fixture <missing argument>", MsgHelp.format(
+                "{0} {1} {2}", new Object[] { null, "fixture" }));
+        assertEquals("<null> fixture", MsgHelp.format("{0} {1}", new Object[] {
+                null, "fixture", "extra" }));
+
+        assertEquals("0 1 2 3 4 5 6 7 8 9", MsgHelp.format(
+                "{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}", new Object[] { "0",
+                        "1", "2", "3", "4", "5", "6", "7", "8", "9" }));
+        assertEquals("9 8 7 6 5 4 3 2 1 0", MsgHelp.format(
+                "{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}", new Object[] { "9",
+                        "8", "7", "6", "5", "4", "3", "2", "1", "0" }));
+
+        assertEquals("0 1 2 3 4 5 6 7 8 9 {10}", MsgHelp.format(
+                "{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}",
+                new Object[] { "0", "1", "2", "3", "4", "5", "6", "7", "8",
+                        "9", "10" }));
+        
+        try {
+            MsgHelp.format(null, new Object[0]);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
+        
+        try {
+            MsgHelp.format("fixture", null);
+            fail("No NPE");
+        } catch (NullPointerException e) {
+        }
+    }
+
+}
\ No newline at end of file

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/luni/util/MsgHelpTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message