fix parseMethod

This commit is contained in:
lurchi 2018-08-17 00:17:53 +02:00
parent 2735d8e089
commit 887af8e41a
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 7 additions and 1 deletions

View File

@ -50,7 +50,7 @@ proc parseKeyword(input: string,
packet: var PsycPacket): tuple[complete: bool, value: string] =
assert(packet.cursor < input.len())
proc validate(c: char): bool = c == '_' or c.isAlphaNumeric()
result = input.getUntil([' ', '\t'], packet, validate)
result = input.getUntil([' ', '\t', '\n'], packet, validate)
if result.complete:
packet.cursor.inc()
if result.value.isNil() or result.value.len() == 0 or result.value[0] != '_':
@ -293,4 +293,10 @@ suite "parser tests":
check(packet.entityHeader[0] == Modifier(op: ':', name: "_hello", value: "world"))
check(packet.entityHeader[1] == Modifier(op: ':', name: "_hallo", value: "welt"))
test "method":
let input = ":_target\talice\n\n_hello_world\n|\n"
while packet.state != ParseState.Complete:
discard parse(input, packet)
check(packet.methodName == "_hello_world")
echo "parser tests completed"