Skip to content

Commit

Permalink
(#1489) Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoss committed Nov 1, 2020
1 parent eb160bf commit d788d88
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/test/java/org/cactoos/scalar/LengthOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.hamcrest.core.IsEqual;
import org.junit.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.HasValues;

/**
* Test case for {@link LengthOf}.
Expand Down Expand Up @@ -187,14 +188,27 @@ public void lengthOfEmptyIterator() {
).affirm();
}

@Test
public void lengthOfEmptyText() {
new Assertion<>(
"Must calculate length of empty string",
new LengthOf(new TextOf("")).intValue(),
new IsEqual<>(0)
).affirm();
}

@Test
public void lengthOfText() {
final Number num = new LengthOf(new TextOf("abcd"));
new Assertion<>(
"Must calculate length of empty iterator",
new LengthOf(
new TextOf("abcd")
).intValue(),
new IsEqual<>(4)
"Must calculate length of non-empty string",
new IterableOf<Number>(
num.intValue(),
num.floatValue(),
num.longValue(),
num.doubleValue()
),
new HasValues<>(4, 4f, 4L, 4d)
).affirm();
}
}

0 comments on commit d788d88

Please sign in to comment.