Add a test for handling missing fields
This commit is contained in:
parent
3cb55e7057
commit
4ffd0b3af3
|
@ -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":
|
||||
var x = HoldsArray(data: @[1, 2, 3, 4])
|
||||
|
||||
|
|
Loading…
Reference in New Issue