forked from functionaljava/functionaljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptionTest.java
More file actions
30 lines (24 loc) · 811 Bytes
/
OptionTest.java
File metadata and controls
30 lines (24 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package fj.data;
import org.junit.Assert;
import org.junit.Test;
import static fj.data.Option.some;
import static org.junit.Assert.assertTrue;
/**
* Created by MarkPerry on 15/01/2015.
*/
public class OptionTest {
@Test
public void equals() {
int max = 4;
assertTrue(some(1).equals(some(1)));
assertTrue(some(List.range(1, max)).equals(some(List.range(1, max))));
}
@Test
public void traverseList() {
int max = 3;
List<Option<Integer>> actual = some(max).traverseList(a -> List.range(1, a + 1));
List<Option<Integer>> expected = List.range(1, max + 1).map(i -> some(i));
System.out.println(String.format("actual: %s, expected: %s", actual.toString(), expected.toString()));
assertTrue(actual.equals(expected));
}
}