Add UTF-16 decoding tests to json module

This commit is contained in:
Daniel Hertz
2015-10-13 14:56:10 -04:00
parent e5bcd287f8
commit 42975e6338

View File

@@ -1220,11 +1220,15 @@ when isMainModule:
assert(false)
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
assert(testJson{"doesnt_exist"}{"anything"}.isNil)
testJson{["c", "d"]} = %true
assert(testJson["c"]["d"].bval)
testJson{["e", "f"]} = %true
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
let startMemory = getOccupiedMem()