Add positive decimal integer parsing tests.

This commit is contained in:
cheatfate 2021-02-10 13:11:27 +02:00 committed by zah
parent 3495122867
commit 4406ab7072
1 changed files with 17 additions and 0 deletions

View File

@ -754,6 +754,23 @@ suite "HTTP server testing suite":
res.isOk() res.isOk()
item[1] == res.get() item[1] == res.get()
test "HttpTable integer parser test":
const TestVectors = [
("", 0'u64), ("0", 0'u64), ("-0", 0'u64), ("0-", 0'u64),
("01", 1'u64), ("001", 1'u64), ("0000000000001", 1'u64),
("18446744073709551615", 0xFFFF_FFFF_FFFF_FFFF'u64),
("18446744073709551616", 1844674407370955161'u64),
("FFFFFFFFFFFFFFFF", 0'u64),
("0123456789ABCDEF", 123456789'u64)
]
for i in 0 ..< 256:
if char(i) in {'0' .. '9'}:
check bytesToDec($char(i)) == uint64(i - ord('0'))
else:
check bytesToDec($char(i)) == 0'u64
for item in TestVectors:
check bytesToDec(item[0]) == item[1]
test "Leaks test": test "Leaks test":
check: check:
getTracker("async.stream.reader").isLeaked() == false getTracker("async.stream.reader").isLeaked() == false