1 package de.fhdw.wtf.common.stream.test;
2
3 import static org.junit.Assert.assertEquals;
4
5 import org.junit.Test;
6
7 import de.fhdw.wtf.common.token.CommentTextToken;
8 import de.fhdw.wtf.common.token.IdentifierToken;
9 import de.fhdw.wtf.common.token.InvalidToken;
10 import de.fhdw.wtf.common.token.Position;
11 import de.fhdw.wtf.common.token.keywords.AbstractToken;
12 import de.fhdw.wtf.common.token.keywords.ClassToken;
13 import de.fhdw.wtf.common.token.keywords.GroupToken;
14 import de.fhdw.wtf.common.token.keywords.PriorToken;
15 import de.fhdw.wtf.common.token.symbols.AsteriskToken;
16 import de.fhdw.wtf.common.token.symbols.ColonToken;
17 import de.fhdw.wtf.common.token.symbols.CurlyBracketCloseToken;
18 import de.fhdw.wtf.common.token.symbols.CurlyBracketOpenToken;
19 import de.fhdw.wtf.common.token.symbols.EqualToken;
20 import de.fhdw.wtf.common.token.symbols.GreaterSymbolToken;
21 import de.fhdw.wtf.common.token.symbols.PlusSymbolToken;
22 import de.fhdw.wtf.common.token.symbols.SemicolonToken;
23 import de.fhdw.wtf.common.token.symbols.SquareBracketCloseToken;
24 import de.fhdw.wtf.common.token.symbols.SquareBracketOpenToken;
25
26 public class LengthTest {
27
28 @Test
29 public void lengthSymbol() {
30 assertEquals(1, SemicolonToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
31 assertEquals(1, AsteriskToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
32 assertEquals(1, CurlyBracketOpenToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
33 assertEquals(1, CurlyBracketCloseToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
34 assertEquals(1, ColonToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
35 assertEquals(1, EqualToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
36 assertEquals(1, GreaterSymbolToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
37 assertEquals(1, PlusSymbolToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
38 assertEquals(1, SquareBracketCloseToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
39 assertEquals(1, SquareBracketOpenToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
40 }
41
42 @Test
43 public void lengthKeywords() {
44 assertEquals(8, AbstractToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
45 assertEquals(5, ClassToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
46 assertEquals(5, GroupToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
47 assertEquals(5, PriorToken.create(Position.create("", 0 + 1, 0 + 1, 0)).getLength());
48 }
49
50 @Test
51 public void lengthIdentifier() {
52 assertEquals(0, IdentifierToken.create("", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
53 assertEquals(1, IdentifierToken.create("A", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
54 assertEquals(2, IdentifierToken.create("AB", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
55 assertEquals(3, IdentifierToken.create("ABC", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
56 }
57
58 @Test
59 public void lengthInvalid() {
60 assertEquals(0, InvalidToken.create("", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
61 assertEquals(1, InvalidToken.create("A", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
62 assertEquals(2, InvalidToken.create("AB", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
63 assertEquals(3, InvalidToken.create("ABC", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
64 }
65
66 @Test
67 public void lengthComment() {
68 assertEquals(0, CommentTextToken.create("", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
69 assertEquals(1, CommentTextToken.create("A", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
70 assertEquals(2, CommentTextToken.create("AB", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
71 assertEquals(3, CommentTextToken.create("ABC", Position.create("", 0 + 1, 0 + 1, 0)).getLength());
72 }
73
74 }