@@ -40,7 +40,7 @@ public class AutoCloseInputStreamTest {
4040
4141 @ BeforeEach
4242 public void setUp () {
43- data = new byte [] { 'x' , 'y' , 'z' };
43+ data = new byte [] {'x' , 'y' , 'z' };
4444 stream = new AutoCloseInputStream (new ByteArrayInputStream (data ) {
4545 @ Override
4646 public void close () {
@@ -57,7 +57,6 @@ public void testClose() throws IOException {
5757 assertEquals (-1 , stream .read (), "read()" );
5858 }
5959
60-
6160 @ Test
6261 public void testRead () throws IOException {
6362 for (final byte element : data ) {
@@ -100,4 +99,26 @@ public void testReadBufferOffsetLength() throws IOException {
10099 assertEquals (-1 , stream .read (b , 0 , b .length ), "read(b, off, len)" );
101100 }
102101
102+ @ Test
103+ public void testResetBeforeEnd () throws IOException {
104+ final String inputStr = "1234" ;
105+ AutoCloseInputStream inputStream = new AutoCloseInputStream (new ByteArrayInputStream (inputStr .getBytes ()));
106+ inputStream .mark (1 );
107+ assertEquals ('1' , inputStream .read ());
108+ inputStream .reset ();
109+ assertEquals ('1' , inputStream .read ());
110+ assertEquals ('2' , inputStream .read ());
111+ inputStream .reset ();
112+ assertEquals ('1' , inputStream .read ());
113+ assertEquals ('2' , inputStream .read ());
114+ assertEquals ('3' , inputStream .read ());
115+ inputStream .reset ();
116+ assertEquals ('1' , inputStream .read ());
117+ assertEquals ('2' , inputStream .read ());
118+ assertEquals ('3' , inputStream .read ());
119+ assertEquals ('4' , inputStream .read ());
120+ inputStream .reset ();
121+ assertEquals ('1' , inputStream .read ());
122+ }
123+
103124}
0 commit comments