forked from functionaljava/functionaljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeTest.java
More file actions
52 lines (41 loc) · 1.27 KB
/
TreeTest.java
File metadata and controls
52 lines (41 loc) · 1.27 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package fj.data;
import org.junit.Assert;
import org.junit.Test;
import static fj.data.Tree.leaf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.*;
/**
* Created by MarkPerry on 29/08/2015.
*/
public class TreeTest {
@Test
public void emptyLength() {
Tree<Integer> t = leaf(1);
assertThat(t.length(), equalTo(1));
}
@Test
public void shallowStreamLength() {
Tree<Integer> t2 = Tree.node(3, Stream.stream(leaf(4), leaf(5)));
assertThat(t2.length(), equalTo(3));
}
@Test
public void deepStreamLength() {
Tree<Integer> t3 = Tree.node(4, Stream.stream(leaf(5), Tree.node(6, Stream.stream(leaf(7), leaf(8)))));
assertThat(t3.length(), equalTo(5));
}
@Test
public void singleIsLeft() {
Tree<Integer> t = leaf(1);
assertThat(t.isLeaf(), equalTo(true));
}
@Test
public void shallowStreamIsLeaf() {
Tree<Integer> t2 = Tree.node(3, Stream.stream(leaf(4), leaf(5)));
assertThat(t2.isLeaf(), equalTo(false));
}
@Test
public void deepStreamIsLeaf() {
Tree<Integer> t3 = Tree.node(4, Stream.stream(leaf(5), Tree.node(6, Stream.stream(leaf(7), leaf(8)))));
assertThat(t3.isLeaf(), equalTo(false));
}
}