Add UTF-16 decoding tests to json module
This commit is contained in:
parent
e5bcd287f8
commit
42975e6338
1 changed files with 7 additions and 3 deletions
|
|
@ -1220,11 +1220,15 @@ when isMainModule:
|
||||||
assert(false)
|
assert(false)
|
||||||
except IndexError: assert(true)
|
except IndexError: assert(true)
|
||||||
|
|
||||||
let testJson = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd" }"""
|
let testJson = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd", "c": "\ud83c\udf83", "d": "\u00E6"}"""
|
||||||
# nil passthrough
|
# nil passthrough
|
||||||
assert(testJson{"doesnt_exist"}{"anything"}.isNil)
|
assert(testJson{"doesnt_exist"}{"anything"}.isNil)
|
||||||
testJson{["c", "d"]} = %true
|
testJson{["e", "f"]} = %true
|
||||||
assert(testJson["c"]["d"].bval)
|
assert(testJson["e"]["f"].bval)
|
||||||
|
|
||||||
|
# make sure UTF-16 decoding works.
|
||||||
|
assert(testJson["c"].str == "🎃")
|
||||||
|
assert(testJson["d"].str == "æ")
|
||||||
|
|
||||||
# make sure no memory leek when parsing invalid string
|
# make sure no memory leek when parsing invalid string
|
||||||
let startMemory = getOccupiedMem()
|
let startMemory = getOccupiedMem()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue