harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r488267 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/font/NumericShaper.java test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java
Date Mon, 18 Dec 2006 13:27:03 GMT
Author: apetrenko
Date: Mon Dec 18 05:27:02 2006
New Revision: 488267

URL: http://svn.apache.org/viewvc?view=rev&rev=488267
Log:
Patch for HARMONY-1584 "[classlib][awt]Compatibility: java.awt.font.NumericShaper.shape()
methods throw different exceptions for illegal parameters on RI and Harmony"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/font/NumericShaper.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/font/NumericShaper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/font/NumericShaper.java?view=diff&rev=488267&r1=488266&r2=488267
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/font/NumericShaper.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/font/NumericShaper.java
Mon Dec 18 05:27:02 2006
@@ -537,18 +537,6 @@
     }
 
     public void shape(char[] text, int start, int count, int context) {
-        int len = text.length;
-
-        if ((start < 0) || ((start + count) > len)) {
-            // awt.19A=start or count arguments are out of text range
-            throw new IndexOutOfBoundsException(Messages.getString("awt.19A")); //$NON-NLS-1$
-        }
-
-        if (count < 0) {
-            // awt.19B=count argument must be positive
-            throw new IllegalArgumentException(Messages.getString("awt.19B")); //$NON-NLS-1$
-        }
-
         if (isContextual()){
             contextualShape(text, start, count, getIndexFromRange(context));
         } else {
@@ -557,18 +545,6 @@
     }
 
     public void shape(char[] text, int start, int count) {
-        int len = text.length;
-
-        if ((start < 0) || ((start + count) > len)) {
-            // awt.19A=start or count arguments are out of text range
-            throw new IndexOutOfBoundsException(Messages.getString("awt.19A")); //$NON-NLS-1$
-        }
-
-        if (count < 0) {
-            // awt.19B=count argument must be positive
-            throw new IllegalArgumentException(Messages.getString("awt.19B")); //$NON-NLS-1$
-        }
-
         if (isContextual()){
             contextualShape(text, start, count, fDefaultContextIndex);
         } else {

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java?view=diff&rev=488267&r1=488266&r2=488267
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/font/NumericShaperTest.java
Mon Dec 18 05:27:02 2006
@@ -357,4 +357,95 @@
         
     }
 
+    /*
+     * Test method for 'java.awt.font.NumericShaper.shape(char[], int, int)' with 
+     * illegal parameters.
+     */
+    public final void testShapeCharArrayIntInt_IllegalArguments() {
+        // regression test for Harmony-1584
+        int ranges = NumericShaper.ARABIC;
+        NumericShaper localNumericShaper = NumericShaper
+                .getContextualShaper(ranges);
+        char[] chars = new char[] {};
+        int start = 0;
+        int count = 1;
+        try {
+            localNumericShaper.shape(chars, start, count);
+            fail("len = 0: ArrayIndexOutOfBoundsException expected!");
+        } catch (ArrayIndexOutOfBoundsException expectedException) {
+            // expected
+        }
+
+        chars = new char[] {'a', 'b', 'c'};
+        start = -1;
+        count = 1;
+        try {
+            localNumericShaper.shape(chars, start, count);
+            fail("start < 0: ArrayIndexOutOfBoundsException expected!");
+        } catch (ArrayIndexOutOfBoundsException expectedException) {
+            // expected
+        }
+
+        // count < 0: silent run expected
+        start = 1;
+        count = -1;
+        localNumericShaper.shape(chars, start, count);
+
+        start = 3;
+        count = 5;
+        try {
+            localNumericShaper.shape(chars, start, count);
+            fail("start + count > len: ArrayIndexOutOfBoundsException expected!");
+        } catch (ArrayIndexOutOfBoundsException expectedException) {
+            // expected
+        }
+
+    }
+
+    /*
+     * Test method for 'java.awt.font.NumericShaper.shape(char[], int, int, int)' with 
+     * illegal parameters. 
+     */
+    public final void testShapeCharArrayIntIntInt_IllegalArguments() {
+        // regression test for Harmony-1584
+        int ranges = NumericShaper.ARABIC;
+        NumericShaper localNumericShaper = NumericShaper
+                .getContextualShaper(ranges);
+        char[] chars = new char[] {};
+        int start = 0;
+        int count = 1;
+        int index = NumericShaper.ARABIC;
+        try {
+            localNumericShaper.shape(chars, start, count, index);
+            fail("len = 0: ArrayIndexOutOfBoundsException expected!");
+        } catch (ArrayIndexOutOfBoundsException expectedException) {
+            //expected
+        }
+
+        chars = new char[] {'a', 'b', 'c'};
+        start = -1;
+        count = 1;
+        try {
+            localNumericShaper.shape(chars, start, count, index);
+            fail("start < 0: ArrayIndexOutOfBoundsException expected!");
+        } catch (ArrayIndexOutOfBoundsException expectedException) {
+            // expected
+        }
+
+        // count < 0: silent run expected
+        start = 1;
+        count = -1;
+        localNumericShaper.shape(chars, start, count, index);
+
+        start = 3;
+        count = 5;
+        try {
+            localNumericShaper.shape(chars, start, count, index);
+            fail("start + count > len: ArrayIndexOutOfBoundsException expected!");
+        } catch (ArrayIndexOutOfBoundsException expectedException) {
+            // expected
+        }
+
+    }
+
 }



Mime
View raw message