-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLiteralTokenFactoryTest.java
More file actions
41 lines (35 loc) · 1.17 KB
/
LiteralTokenFactoryTest.java
File metadata and controls
41 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class LiteralTokenFactoryTest {
@Test
public void testFoundLength1() {
LiteralTokenFactory f = new LiteralTokenFactory();
f.setText("a=9x");
boolean found = f.find(2);
assertTrue(found);
assertEquals(1, f.getTokenLength());
assertEquals(2, f.getTokenStartPosition());
assertEquals("9", f.getTokenText());
assertEquals(TokenType.LITERAL, f.getToken().getType());
}
@Test
public void testFoundLength3() {
LiteralTokenFactory f = new LiteralTokenFactory();
f.setText("abc=123x");
boolean found = f.find(4);
assertTrue(found);
assertEquals(3, f.getTokenLength());
assertEquals(4, f.getTokenStartPosition());
assertEquals("123", f.getTokenText());
assertEquals(TokenType.LITERAL, f.getToken().getType());
}
@Test
public void testNoMatchNotFound() {
LiteralTokenFactory f = new LiteralTokenFactory();
f.setText("abc=xyz");
boolean found = f.find(4);
assertFalse(found);
}
}