Skip to content

Commit

Permalink
#478 added a test show how a range of fibonacci numbers between 1 and…
Browse files Browse the repository at this point in the history
… 100 is done. Just for fun.
  • Loading branch information
svendiedrichsen committed Dec 1, 2017
1 parent ee25eb7 commit f6f5ec0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/test/java/org/cactoos/iterable/RangeOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import org.cactoos.Func;
import org.cactoos.collection.CollectionOf;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -52,6 +53,30 @@ public final void testIntegerRange() {
);
}

@Test
public final void testIntegerFibonacciRange() {
MatcherAssert.assertThat(
"Can't generate a range of fibonacci integers",
new CollectionOf<>(
new RangeOf.Integer(
1,
100,
new Func<Integer, Integer>() {
private int last;
@Override
public Integer apply(
final Integer input) throws Exception {
final int next = this.last + input;
this.last = input;
return next;
}
}
)
),
Matchers.contains(1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89)
);
}

@Test
public final void testLongRange() {
MatcherAssert.assertThat(
Expand Down

0 comments on commit f6f5ec0

Please sign in to comment.