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 2024/04/03 14:15:15 UTC
(commons-io) 03/04: Sort members
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
commit f7c43343679d65129200f88aa82744dfe43d2d76
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Apr 3 08:32:40 2024 -0400
Sort members
---
.../commons/io/input/BoundedInputStreamTest.java | 74 +++++++++++-----------
1 file changed, 37 insertions(+), 37 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
index 11a3acfb6..ad3d50edc 100644
--- a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
@@ -285,6 +285,43 @@ public class BoundedInputStreamTest {
}
}
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testReadSingle() throws Exception {
+ final byte[] helloWorld = "Hello World".getBytes(StandardCharsets.UTF_8);
+ final byte[] hello = "Hello".getBytes(StandardCharsets.UTF_8);
+ // limit = length
+ try (BoundedInputStream bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length)) {
+ assertTrue(bounded.markSupported());
+ for (int i = 0; i < helloWorld.length; i++) {
+ assertEquals(helloWorld[i], bounded.read(), "limit = length byte[" + i + "]");
+ }
+ assertEquals(-1, bounded.read(), "limit = length end");
+ // should be invariant
+ assertTrue(bounded.markSupported());
+ }
+ // limit > length
+ try (BoundedInputStream bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length + 1)) {
+ assertTrue(bounded.markSupported());
+ for (int i = 0; i < helloWorld.length; i++) {
+ assertEquals(helloWorld[i], bounded.read(), "limit > length byte[" + i + "]");
+ }
+ assertEquals(-1, bounded.read(), "limit > length end");
+ // should be invariant
+ assertTrue(bounded.markSupported());
+ }
+ // limit < length
+ try (BoundedInputStream bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), hello.length)) {
+ assertTrue(bounded.markSupported());
+ for (int i = 0; i < hello.length; i++) {
+ assertEquals(hello[i], bounded.read(), "limit < length byte[" + i + "]");
+ }
+ assertEquals(-1, bounded.read(), "limit < length end");
+ // should be invariant
+ assertTrue(bounded.markSupported());
+ }
+ }
+
@Test
public void testReset() throws Exception {
final byte[] helloWorld = "Hello World".getBytes(StandardCharsets.UTF_8);
@@ -323,41 +360,4 @@ public class BoundedInputStreamTest {
assertTrue(bounded.markSupported());
}
}
-
- @SuppressWarnings("deprecation")
- @Test
- public void testReadSingle() throws Exception {
- final byte[] helloWorld = "Hello World".getBytes(StandardCharsets.UTF_8);
- final byte[] hello = "Hello".getBytes(StandardCharsets.UTF_8);
- // limit = length
- try (BoundedInputStream bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length)) {
- assertTrue(bounded.markSupported());
- for (int i = 0; i < helloWorld.length; i++) {
- assertEquals(helloWorld[i], bounded.read(), "limit = length byte[" + i + "]");
- }
- assertEquals(-1, bounded.read(), "limit = length end");
- // should be invariant
- assertTrue(bounded.markSupported());
- }
- // limit > length
- try (BoundedInputStream bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length + 1)) {
- assertTrue(bounded.markSupported());
- for (int i = 0; i < helloWorld.length; i++) {
- assertEquals(helloWorld[i], bounded.read(), "limit > length byte[" + i + "]");
- }
- assertEquals(-1, bounded.read(), "limit > length end");
- // should be invariant
- assertTrue(bounded.markSupported());
- }
- // limit < length
- try (BoundedInputStream bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), hello.length)) {
- assertTrue(bounded.markSupported());
- for (int i = 0; i < hello.length; i++) {
- assertEquals(hello[i], bounded.read(), "limit < length byte[" + i + "]");
- }
- assertEquals(-1, bounded.read(), "limit < length end");
- // should be invariant
- assertTrue(bounded.markSupported());
- }
- }
}