Changeset 6cdb152b7a7958a07196bbe96ad93e1f1f80ef99
- Timestamp:
- 12/29/07 13:52:55
(8 months ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1198932775 +0100
- git-parent:
[9eeebea1c9a7144e212f2d0cd6eaabdbc4a368cb]
- git-author:
- Christopher Jung <bktheg@web.de> 1198932775 +0100
- Message:
Unterstuetzung fuer Positionen als Rollenattribut
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r23aa517 |
r6cdb152 |
|
| 18 | 18 | */ |
|---|
| 19 | 19 | package net.driftingsouls.ds2.server.scripting.roles.parser; |
|---|
| | 20 | |
|---|
| | 21 | import net.driftingsouls.ds2.server.Location; |
|---|
| 20 | 22 | |
|---|
| 21 | 23 | import org.antlr.runtime.ANTLRStringStream; |
|---|
| … | … | |
| 94 | 96 | value = Long.parseLong(valueStr); |
|---|
| 95 | 97 | break; |
|---|
| | 98 | |
|---|
| | 99 | case RoleParser.Location: |
|---|
| | 100 | value = Location.fromString(valueStr); |
|---|
| | 101 | break; |
|---|
| 96 | 102 | } |
|---|
| 97 | 103 | |
|---|
| r23aa517 |
r6cdb152 |
|
| 43 | 43 | |
|---|
| 44 | 44 | value |
|---|
| 45 | | : ( Number | Text ) |
|---|
| | 45 | : ( Number | Text | Location ) |
|---|
| | 46 | ; |
|---|
| | 47 | |
|---|
| | 48 | Location |
|---|
| | 49 | : Digit+ ':' Digit+ '/' Digit+ |
|---|
| 46 | 50 | ; |
|---|
| 47 | 51 | |
|---|
| … | … | |
| 50 | 54 | ; |
|---|
| 51 | 55 | |
|---|
| 52 | | Number : '1'..'9' Numeric |
|---|
| | 56 | Number : '1'..'9' Digit* |
|---|
| 53 | 57 | ; |
|---|
| 54 | 58 | |
|---|
| r23aa517 |
r6cdb152 |
|
| 21 | 21 | import static org.hamcrest.CoreMatchers.*; |
|---|
| 22 | 22 | import static org.junit.Assert.*; |
|---|
| | 23 | import net.driftingsouls.ds2.server.Location; |
|---|
| 23 | 24 | |
|---|
| 24 | 25 | import org.junit.Test; |
|---|
| … | … | |
| 91 | 92 | assertNotNull(role); |
|---|
| 92 | 93 | assertThat(role.getRoleName(), is("TestRole")); |
|---|
| 93 | | assertEquals(role.getAttribute("Attribute1"), Long.valueOf(5)); |
|---|
| 94 | | assertEquals(role.getAttribute("Attribute2"), "Test\"0123\\Test"); |
|---|
| | 94 | assertEquals(Long.valueOf(5), role.getAttribute("Attribute1")); |
|---|
| | 95 | assertEquals("Test\"0123\\Test", role.getAttribute("Attribute2")); |
|---|
| | 96 | } |
|---|
| | 97 | |
|---|
| | 98 | /** |
|---|
| | 99 | * Testet die Parsefunktion bei Koordinaten |
|---|
| | 100 | */ |
|---|
| | 101 | @Test |
|---|
| | 102 | public void testAttributeLocationParse() { |
|---|
| | 103 | final String roleDef = "role: TestRole2\n" + |
|---|
| | 104 | "Attribute1: 1:23/45"; |
|---|
| | 105 | RoleDefinition role = Parser.parse(roleDef); |
|---|
| | 106 | assertNotNull(role); |
|---|
| | 107 | assertThat(role.getRoleName(), is("TestRole2")); |
|---|
| | 108 | assertEquals(new Location(1, 23, 45), role.getAttribute("Attribute1")); |
|---|
| 95 | 109 | } |
|---|
| 96 | 110 | } |
|---|