You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/01/21 21:48:54 UTC
[commons-io] branch master updated: Add test case related to
[IO-568].
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push:
new 98e23e0 Add test case related to [IO-568].
98e23e0 is described below
commit 98e23e025b39debe065646531d557152b006ba6f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jan 21 16:48:48 2021 -0500
Add test case related to [IO-568].
---
.../commons/io/input/AutoCloseInputStreamTest.java | 25 ++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java b/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java
index c067f6f..0d3c20b 100644
--- a/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java
@@ -40,7 +40,7 @@ public class AutoCloseInputStreamTest {
@BeforeEach
public void setUp() {
- data = new byte[] { 'x', 'y', 'z' };
+ data = new byte[] {'x', 'y', 'z'};
stream = new AutoCloseInputStream(new ByteArrayInputStream(data) {
@Override
public void close() {
@@ -57,7 +57,6 @@ public class AutoCloseInputStreamTest {
assertEquals(-1, stream.read(), "read()");
}
-
@Test
public void testRead() throws IOException {
for (final byte element : data) {
@@ -100,4 +99,26 @@ public class AutoCloseInputStreamTest {
assertEquals(-1, stream.read(b, 0, b.length), "read(b, off, len)");
}
+ @Test
+ public void testResetBeforeEnd() throws IOException {
+ final String inputStr = "1234";
+ AutoCloseInputStream inputStream = new AutoCloseInputStream(new ByteArrayInputStream(inputStr.getBytes()));
+ inputStream.mark(1);
+ assertEquals('1', inputStream.read());
+ inputStream.reset();
+ assertEquals('1', inputStream.read());
+ assertEquals('2', inputStream.read());
+ inputStream.reset();
+ assertEquals('1', inputStream.read());
+ assertEquals('2', inputStream.read());
+ assertEquals('3', inputStream.read());
+ inputStream.reset();
+ assertEquals('1', inputStream.read());
+ assertEquals('2', inputStream.read());
+ assertEquals('3', inputStream.read());
+ assertEquals('4', inputStream.read());
+ inputStream.reset();
+ assertEquals('1', inputStream.read());
+ }
+
}