Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Feb 6, 2020
2 parents 2f52b54 + b54cae4 commit c941b2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @since 0.31
*/
public final class HeadInput implements Input {
public final class HeadOf implements Input {

/**
* The original input.
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -51,13 +51,27 @@ 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";
new Assertion<>(
"must limit to at most the number of available bytes",
new TextOf(
new HeadInput(
new HeadOf(
new InputOf(input),
35
)
Expand Down

0 comments on commit c941b2d

Please sign in to comment.