Skip to content

Commit f2d4ab5

Browse files
committed
#43 added test cases for Option.map/flatMap with failing functions
1 parent f1a67bf commit f2d4ab5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/test/java/javascalautils/TestSome.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,27 @@ public void map() {
126126
assertEquals(TEXT_VALUE.length(), mapped.get().intValue());
127127
}
128128

129+
@Test(expected = BrokenFunctionException.class)
130+
public void map_fail() {
131+
option.map(v -> {
132+
throw new Exception("Oh darn, this went FUBAR!");
133+
});
134+
}
135+
129136
@Test
130137
public void flatMap() {
131138
Option<Integer> mapped = option.flatMap(v -> Option.apply(v.length()));
132139
assertTrue(mapped.isDefined());
133140
assertEquals(TEXT_VALUE.length(), mapped.get().intValue());
134141
}
135142

143+
@Test(expected = BrokenFunctionException.class)
144+
public void flatMap_fail() {
145+
option.flatMap(v -> {
146+
throw new Exception("Oh darn, this went FUBAR!");
147+
});
148+
}
149+
136150
@Test
137151
public void isEmpty() {
138152
assertFalse(option.isEmpty());

0 commit comments

Comments
 (0)