1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.lang3.function;
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21 import static org.junit.jupiter.api.Assertions.assertFalse;
22 import static org.junit.jupiter.api.Assertions.assertThrows;
23 import static org.junit.jupiter.api.Assertions.assertTrue;
24
25 import java.io.IOException;
26
27 import org.apache.commons.lang3.AbstractLangTest;
28 import org.junit.jupiter.api.Test;
29
30
31
32
33 class FailableBooleanSupplierTest extends AbstractLangTest {
34
35 @Test
36 void testGetAsBoolean_returnsFalse() throws IOException {
37 final FailableBooleanSupplier<IOException> supplier = () -> false;
38 assertFalse(supplier.getAsBoolean());
39 }
40
41 @Test
42 void testGetAsBoolean_returnsTrue() throws IOException {
43 final FailableBooleanSupplier<IOException> supplier = () -> true;
44 assertTrue(supplier.getAsBoolean());
45 }
46
47 @Test
48 void testGetAsBoolean_throwsException() {
49 final IOException expected = new IOException("fail");
50 final FailableBooleanSupplier<IOException> supplier = () -> {
51 throw expected;
52 };
53 final IOException thrown = assertThrows(IOException.class, supplier::getAsBoolean);
54 assertEquals(expected, thrown);
55 }
56 }