Skip to content

Commit a6a0d21

Browse files
committed
add tests for zero elements of monoids
1 parent b710672 commit a6a0d21

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

core/src/test/java/fj/MonoidTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,21 @@ public void union_monoid_test() {
4040
assertThat(actual, is(Set.set(Ord.intOrd, 1, 2, 3, 4, 5, 6)));
4141
}
4242

43+
@Test
44+
public void intersection_monoid_zero_test() {
45+
Bounded<Integer> integersBounded = Bounded.bounded(0, 10);
46+
Monoid<Set<Integer>> monoid = Monoid.setIntersectionMonoid(integersBounded, Enumerator.intEnumerator, Ord.intOrd);
47+
Set<Integer> set = Set.set(Ord.intOrd, 1, 2, 3, 4);
48+
Set<Integer> zero = monoid.zero();
49+
assertThat(monoid.sum(zero, set), is(set));
50+
}
51+
52+
@Test
53+
public void union_monoid_zero_test() {
54+
Monoid<Set<Integer>> monoid = Monoid.setMonoid(Ord.intOrd);
55+
Set<Integer> set = Set.set(Ord.intOrd, 1, 2, 3, 4);
56+
Set<Integer> zero = monoid.zero();
57+
assertThat(monoid.sum(zero, set), is(set));
58+
}
59+
4360
}

0 commit comments

Comments
 (0)