mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 23:35:22 +00:00
test case for #2367
This commit is contained in:
@@ -1203,6 +1203,17 @@ when isMainModule:
|
||||
testJson{["c", "d"]} = %true
|
||||
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 `$`
|
||||
let stringified = $testJson
|
||||
let parsedAgain = parseJson(stringified)
|
||||
|
||||
Reference in New Issue
Block a user