Skip to content

Commit 606f1e7

Browse files
committed
add tests for set semigroup
1 parent 4b25bf8 commit 606f1e7

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package fj;
2+
3+
import fj.data.Set;
4+
import org.junit.Test;
5+
6+
import static org.hamcrest.core.Is.is;
7+
import static org.hamcrest.MatcherAssert.assertThat;
8+
9+
public class SemigroupTest {
10+
11+
@Test
12+
public void intersection_semigroup_test() {
13+
Semigroup<Set<Integer>> intersectionSemigroup = Semigroup.setIntersectionSemigroup();
14+
Set<Integer> first = Set.set(Ord.intOrd, 1, 2, 3, 4);
15+
Set<Integer> second = Set.set(Ord.intOrd, 3, 4, 5, 6);
16+
assertThat(intersectionSemigroup.sum(first, second), is(Set.set(Ord.intOrd, 3, 4)));
17+
}
18+
19+
@Test
20+
public void union_semigroup_test() {
21+
Semigroup<Set<Integer>> unionSemigroup = Semigroup.setSemigroup();
22+
Set<Integer> first = Set.set(Ord.intOrd, 1, 2, 3, 4);
23+
Set<Integer> second = Set.set(Ord.intOrd, 3, 4, 5, 6);
24+
assertThat(unionSemigroup.sum(first, second), is(Set.set(Ord.intOrd, 1, 2, 3, 4, 5, 6)));
25+
}
26+
}

0 commit comments

Comments
 (0)