garydgregory commented on code in PR #860:
URL: https://github.com/apache/commons-io/pull/860#discussion_r3435099341


##########
src/test/java/org/apache/commons/io/input/BoundedReaderTest.java:
##########
@@ -242,4 +243,42 @@ void testSkipTest() throws IOException {
             assertEquals(-1, mr.read());
         }
     }
+
+    @Test
+    void testSkipDoesNotExceedBound() throws IOException {
+        try (BoundedReader mr = new BoundedReader(new 
StringReader("01234567890"), 3)) {
+            assertEquals(3, mr.skip(100));
+            assertEquals(-1, mr.read());
+        }
+    }
+
+    @Test
+    void testSkipDoesNotOverflowCharsRead() throws IOException {
+        try (BoundedReader mr = new BoundedReader(new 
StringReader("01234567890"), 3)) {
+            assertEquals(3, mr.skip(Long.MAX_VALUE));
+            assertEquals(-1, mr.read());
+        }
+    }
+
+    @Test
+    void testSkipUsesActualSkippedCount() throws IOException {
+        try (BoundedReader mr = new BoundedReader(new FilterReader(new 
StringReader("01234567890")) {
+            @Override
+            public long skip(final long n) throws IOException {
+                return super.skip(Math.min(n, 2));
+            }
+        }, 5)) {
+            assertEquals(2, mr.skip(5));
+            assertEquals('2', mr.read());
+        }
+    }
+
+    @Test
+    void testSkipRespectsReadAheadLimit() throws IOException {
+        try (BoundedReader mr = new BoundedReader(new 
StringReader("01234567890"), 10)) {
+            mr.mark(3);

Review Comment:
   Please review the contract of the mark and reset methods and notice the word 
"attempt". You're trying to turn override one feature (reading) with another 
(mark/reset).
   
   Unless you can provide a strong argument that marking should act as a hard 
limit, I don't see a use case here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to