-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokenTest.java
More file actions
36 lines (30 loc) · 1.01 KB
/
TokenTest.java
File metadata and controls
36 lines (30 loc) · 1.01 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
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class TokenTest {
@Test
public void testLength1() {
Token t = new Token(TokenType.PLUS, "+", 0);
assertEquals(TokenType.PLUS, t.getType());
assertEquals("+", t.getText());
assertEquals(0, t.getStartPosition());
assertEquals(1, t.getEndPosition());
}
@Test
public void testLength2() {
Token t = new Token(TokenType.IDENTIFIER, "id", 3);
assertEquals(TokenType.IDENTIFIER, t.getType());
assertEquals("id", t.getText());
assertEquals(3, t.getStartPosition());
assertEquals(5, t.getEndPosition());
}
@Test
public void testLength3() {
Token t = new Token(TokenType.LITERAL, "456", 60);
assertEquals(TokenType.LITERAL, t.getType());
assertEquals("456", t.getText());
assertEquals(60, t.getStartPosition());
assertEquals(63, t.getEndPosition());
}
}