Add a test for handling missing fields

This commit is contained in:
Zahary Karadjov 2019-04-08 15:29:11 +03:00
parent 3cb55e7057
commit 4ffd0b3af3
1 changed files with 15 additions and 0 deletions

View File

@ -62,6 +62,21 @@ suite "toJson tests":
} }
""" """
test "handle missing fields":
let json = dedent"""
{
"y": "test",
"distance": 20
}
"""
let decoded = Json.decode(json, Simple)
check:
decoded.x == 0
decoded.y == "test"
decoded.distance.int == 20
test "arrays are printed correctly": test "arrays are printed correctly":
var x = HoldsArray(data: @[1, 2, 3, 4]) var x = HoldsArray(data: @[1, 2, 3, 4])