1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.analysis.matchers;
20
21
22 import org.junit.jupiter.api.BeforeEach;
23 import org.junit.jupiter.api.Test;
24
25 import static org.junit.jupiter.api.Assertions.assertEquals;
26
27 import org.apache.rat.analysis.IHeaderMatcher.State;
28
29 public class FullTextMatcherTest {
30
31 FullTextMatcher target = new FullTextMatcher("Hello world");
32
33 @BeforeEach
34 public void setup() {
35 target.reset();
36 }
37
38 @Test
39 public void testMatch() {
40 assertEquals( State.i, target.currentState());
41 assertEquals( State.i, target.matches("what in the world"));
42 assertEquals( State.i, target.currentState());
43 assertEquals( State.t, target.matches("hello world"));
44 assertEquals( State.t, target.currentState());
45 assertEquals( State.t, target.finalizeState());
46 assertEquals( State.t, target.currentState());
47 target.reset();
48 assertEquals( State.i, target.currentState());
49 }
50
51 @Test
52 public void testNoMatch() {
53 assertEquals( State.i, target.currentState());
54 assertEquals( State.i, target.matches("what in the world"));
55 assertEquals( State.i, target.currentState());
56 assertEquals( State.i, target.matches("hello there"));
57 assertEquals( State.i, target.currentState());
58 assertEquals( State.f, target.finalizeState());
59 assertEquals( State.f, target.currentState());
60 target.reset();
61 assertEquals( State.i, target.currentState());
62 }
63
64 @Test
65 public void testTrueIsAlwaysTrue() {
66 assertEquals( State.i, target.currentState());
67 assertEquals( State.t, target.matches("hello world"));
68 assertEquals( State.t, target.currentState());
69 assertEquals( State.t, target.matches("A non matching line"));
70 assertEquals( State.t, target.currentState());
71 assertEquals( State.t, target.finalizeState());
72 assertEquals( State.t, target.currentState());
73 target.reset();
74 assertEquals( State.i, target.currentState());
75 }
76 }