test case for #2367
This commit is contained in:
parent
58e1068f73
commit
16fe63180f
1 changed files with 11 additions and 0 deletions
|
|
@ -1203,6 +1203,17 @@ when isMainModule:
|
||||||
testJson{["c", "d"]} = %true
|
testJson{["c", "d"]} = %true
|
||||||
assert(testJson["c"]["d"].bval)
|
assert(testJson["c"]["d"].bval)
|
||||||
|
|
||||||
|
# make sure no memory leek when parsing invalid string
|
||||||
|
let startMemory = getOccupiedMem()
|
||||||
|
for i in 0 .. 10000:
|
||||||
|
try:
|
||||||
|
discard parseJson"""{ invalid"""
|
||||||
|
except:
|
||||||
|
discard
|
||||||
|
# memory diff should less than 2M
|
||||||
|
assert(abs(getOccupiedMem() - startMemory) < 2 * 1024 * 1024)
|
||||||
|
|
||||||
|
|
||||||
# test `$`
|
# test `$`
|
||||||
let stringified = $testJson
|
let stringified = $testJson
|
||||||
let parsedAgain = parseJson(stringified)
|
let parsedAgain = parseJson(stringified)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue