1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.atlassian.fugue;
17
18 import org.junit.Test;
19
20 import java.util.function.Function;
21
22 import static org.hamcrest.Matchers.contains;
23 import static org.junit.Assert.assertThat;
24
25 public class IterablesUnfoldTest {
26 private static final Function<Integer, Option<Pair<String, Integer>>> F = i -> (i > 4) ? Option.<Pair<String, Integer>> none() : Option.some(Pair
27 .pair(i.toString(), i + 1));
28
29 @Test public void unfold() {
30 assertThat(Iterables.unfold(F, 1), contains("1", "2", "3", "4"));
31 }
32
33 @Test(expected = NullPointerException.class) public void unfoldNull() {
34 Iterables.unfold(null, 0);
35 }
36 }