-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdentifierTokenFactoryTest.java
More file actions
42 lines (35 loc) · 1.2 KB
/
IdentifierTokenFactoryTest.java
File metadata and controls
42 lines (35 loc) · 1.2 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
42
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class IdentifierTokenFactoryTest {
@Test
public void testFoundLength1() {
IdentifierTokenFactory f = new IdentifierTokenFactory();
f.setText("a=9x");
boolean found = f.find(3);
assertTrue(found);
assertEquals(1, f.getTokenLength());
assertEquals(3, f.getTokenStartPosition());
assertEquals("x", f.getTokenText());
assertEquals(TokenType.IDENTIFIER, f.getToken().getType());
}
@Test
public void testFoundLength3() {
IdentifierTokenFactory f = new IdentifierTokenFactory();
f.setText("abc=1x1a+");
boolean found = f.find(5);
assertTrue(found);
assertEquals(3, f.getTokenLength());
assertEquals(5, f.getTokenStartPosition());
assertEquals("x1a", f.getTokenText());
assertEquals(TokenType.IDENTIFIER, f.getToken().getType());
}
@Test
public void testNoMatchNotFound() {
IdentifierTokenFactory f = new IdentifierTokenFactory();
f.setText("123=456");
boolean found = f.find(4);
assertFalse(found);
}
}