Add hexValue tests.
This commit is contained in:
parent
4e9a857b90
commit
25688cd0aa
|
@ -36,7 +36,7 @@ proc LT(x, y: uint32): uint32 {.inline.} =
|
|||
let z = x - y
|
||||
(z xor ((y xor x) and (y xor z))) shr 31
|
||||
|
||||
proc hexValue(c: byte): int =
|
||||
proc hexValue*(c: byte): int =
|
||||
# This is nim adaptation of
|
||||
# https://github.com/pornin/CTTK/blob/master/src/hex.c#L28-L52
|
||||
let x = uint32(c) - 0x30'u32
|
||||
|
|
|
@ -629,6 +629,19 @@ suite "ChunkedStream test suite":
|
|||
result = res
|
||||
check waitFor(testVectors2(initTAddress("127.0.0.1:46001"))) == true
|
||||
|
||||
test "ChunkedStream hex decoding test":
|
||||
for i in 0 ..< 256:
|
||||
let ch = char(i)
|
||||
case ch
|
||||
of '0' .. '9':
|
||||
check hexValue(byte(ch)) == ord(ch) - ord('0')
|
||||
of 'a' .. 'f':
|
||||
check hexValue(byte(ch)) == ord(ch) - ord('a') + 10
|
||||
of 'A' .. 'F':
|
||||
check hexValue(byte(ch)) == ord(ch) - ord('A') + 10
|
||||
else:
|
||||
check hexValue(byte(ch)) == -1
|
||||
|
||||
test "ChunkedStream leaks test":
|
||||
check:
|
||||
getTracker("async.stream.reader").isLeaked() == false
|
||||
|
|
Loading…
Reference in New Issue