From 8bbef90bc5af19a261a35b8dcb603e3427edca63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20No=C3=ABl?= Date: Sat, 1 Feb 2020 14:49:10 +0100 Subject: [PATCH 1/2] (#1239) HeadInput is renamed to HeadOf --- .../java/org/cactoos/io/{HeadInput.java => HeadOf.java} | 4 ++-- .../cactoos/io/{HeadInputTest.java => HeadOfTest.java} | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/main/java/org/cactoos/io/{HeadInput.java => HeadOf.java} (94%) rename src/test/java/org/cactoos/io/{HeadInputTest.java => HeadOfTest.java} (94%) diff --git a/src/main/java/org/cactoos/io/HeadInput.java b/src/main/java/org/cactoos/io/HeadOf.java similarity index 94% rename from src/main/java/org/cactoos/io/HeadInput.java rename to src/main/java/org/cactoos/io/HeadOf.java index 1f2badf317..27717e4082 100644 --- a/src/main/java/org/cactoos/io/HeadInput.java +++ b/src/main/java/org/cactoos/io/HeadOf.java @@ -31,7 +31,7 @@ * * @since 0.31 */ -public final class HeadInput implements Input { +public final class HeadOf implements Input { /** * The original input. @@ -48,7 +48,7 @@ public final class HeadInput implements Input { * @param orig The original input. * @param len Limit of bytes that can be read from the beginning. */ - public HeadInput(final Input orig, final int len) { + public HeadOf(final Input orig, final int len) { this.origin = orig; this.length = len; } diff --git a/src/test/java/org/cactoos/io/HeadInputTest.java b/src/test/java/org/cactoos/io/HeadOfTest.java similarity index 94% rename from src/test/java/org/cactoos/io/HeadInputTest.java rename to src/test/java/org/cactoos/io/HeadOfTest.java index 65e1ed554f..ae3f4c29a9 100644 --- a/src/test/java/org/cactoos/io/HeadInputTest.java +++ b/src/test/java/org/cactoos/io/HeadOfTest.java @@ -29,20 +29,20 @@ import org.llorllale.cactoos.matchers.TextHasString; /** - * Test cases for {@link HeadInput}. + * Test cases for {@link HeadOf}. * * @since 0.31 * @checkstyle JavadocMethodCheck (500 lines) * @checkstyle MagicNumberCheck (500 lines) */ -public final class HeadInputTest { +public final class HeadOfTest { @Test public void readsHeadOfLongerInput() throws Exception { new Assertion<>( "must limit exactly the number of read bytes", new TextOf( - new HeadInput( + new HeadOf( new InputOf("readsHeadOfLongerInput"), 5 ) @@ -57,7 +57,7 @@ public void readsHeadOfShorterInput() throws Exception { new Assertion<>( "must limit to at most the number of available bytes", new TextOf( - new HeadInput( + new HeadOf( new InputOf(input), 35 ) From b54cae495c3367536c59c2ea20803f4dd4fcca70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20No=C3=ABl?= Date: Mon, 3 Feb 2020 19:08:01 +0100 Subject: [PATCH 2/2] (#1239) Add extra tests for HeadOf --- src/test/java/org/cactoos/io/HeadOfTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/org/cactoos/io/HeadOfTest.java b/src/test/java/org/cactoos/io/HeadOfTest.java index ae3f4c29a9..2b563c3d5c 100644 --- a/src/test/java/org/cactoos/io/HeadOfTest.java +++ b/src/test/java/org/cactoos/io/HeadOfTest.java @@ -51,6 +51,20 @@ public void readsHeadOfLongerInput() throws Exception { ).affirm(); } + @Test + public void readsEmptyHeadOfInput() throws Exception { + new Assertion<>( + "must limit to 0 the number of read bytes", + new TextOf( + new HeadOf( + new InputOf("readsEmptyHeadOfInput"), + 0 + ) + ), + new TextHasString("") + ).affirm(); + } + @Test public void readsHeadOfShorterInput() throws Exception { final String input = "readsHeadOfShorterInput";