harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r553757 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/CharArrayReader.java test/api/common/tests/api/java/io/CharArrayReaderTest.java
Date Fri, 06 Jul 2007 06:26:10 GMT
Author: tonywu
Date: Thu Jul  5 23:26:09 2007
New Revision: 553757

URL: http://svn.apache.org/viewvc?view=rev&rev=553757
Log:
Fix HARMONY-4357 ([classlib][luni] Compatibility: CharArrayReader.reset() behavior differs
on Harmony and RI if the stream hasn't been marked)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java?view=diff&rev=553757&r1=553756&r2=553757
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java
Thu Jul  5 23:26:09 2007
@@ -79,6 +79,7 @@
         }
         this.buf = buf;
         this.pos = offset;
+        this.markedPos = offset;
 
         /* This is according to spec */
         this.count = this.pos + length < buf.length ? length : buf.length;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java?view=diff&rev=553757&r1=553756&r2=553757
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/CharArrayReaderTest.java
Thu Jul  5 23:26:09 2007
@@ -162,9 +162,10 @@
 	}
 
 	/**
+	 * @throws IOException 
 	 * @tests java.io.CharArrayReader#reset()
 	 */
-	public void test_reset() {
+	public void test_reset() throws IOException {
 		// Test for method void java.io.CharArrayReader.reset()
 		try {
 			cr = new CharArrayReader(hw);
@@ -177,7 +178,20 @@
 		} catch (IOException e) {
 			fail("Exception during reset test : " + e.getMessage());
 		}
-	}
+        
+        // Regression for HARMONY-4357
+        String str = "offsetHello world!";
+        char[] data = new char[str.length()];
+        str.getChars(0, str.length(), data, 0);
+        int offsetLength = 6;
+        int length = data.length - offsetLength;
+
+        CharArrayReader reader = new CharArrayReader(data, offsetLength, length);
+        reader.reset();
+        System.out.print("\nAfter reset(): ");
+        for (int i = 0; i < length; i++)
+            assertEquals(data[offsetLength + i], (char) reader.read());
+    }
 
 	/**
 	 * @tests java.io.CharArrayReader#skip(long)



Mime
View raw message