|
25 | 25 | import static org.junit.jupiter.api.Assertions.assertNotSame;
|
26 | 26 | import static org.junit.jupiter.api.Assertions.assertSame;
|
27 | 27 | import static org.junit.jupiter.api.Assertions.assertThrows;
|
| 28 | +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; |
28 | 29 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
29 | 30 | import static org.junit.jupiter.api.Assertions.fail;
|
30 | 31 | import static org.mockito.Mockito.clearInvocations;
|
|
51 | 52 | import java.io.StringReader;
|
52 | 53 | import java.math.BigDecimal;
|
53 | 54 | import java.nio.charset.StandardCharsets;
|
| 55 | +import java.util.ArrayList; |
54 | 56 | import java.util.HashMap;
|
55 | 57 | import java.util.HashSet;
|
| 58 | +import java.util.List; |
56 | 59 | import java.util.Map;
|
57 | 60 | import java.util.NoSuchElementException;
|
58 | 61 | import java.util.Objects;
|
|
65 | 68 | "resource"})
|
66 | 69 | class IntegrationTest extends AbstractIntegrationTest {
|
67 | 70 |
|
| 71 | + @Test |
| 72 | + void testIteration_Empty() throws Exception { |
| 73 | + final List<PrologTerm> termList = new ArrayList<>(); |
| 74 | + try (final PrologParser parser = parseEd("")) { |
| 75 | + while (parser.hasNext()) { |
| 76 | + termList.add(parser.next()); |
| 77 | + } |
| 78 | + } |
| 79 | + assertTrue(termList.isEmpty()); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + void testIteration_Empty_NoSuchElementException() throws Exception { |
| 84 | + try (final PrologParser parser = parseEd("")) { |
| 85 | + assertThrowsExactly(NoSuchElementException.class, parser::next); |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + @Test |
| 90 | + void testIteration_Presented() throws Exception { |
| 91 | + final List<PrologTerm> termList = new ArrayList<>(); |
| 92 | + try (final PrologParser parser = parseEd("one(1). two(2). three(3).")) { |
| 93 | + while (parser.hasNext()) { |
| 94 | + termList.add(parser.next()); |
| 95 | + } |
| 96 | + } |
| 97 | + assertEquals(3, termList.size()); |
| 98 | + } |
| 99 | + |
68 | 100 | @Test
|
69 | 101 | void testReadingClausesTokensAndCharsFromSameParser() throws Exception {
|
70 | 102 | try (final PrologParser parser = parseEd("lsome(a). alone. next(b).c")) {
|
|
0 commit comments