Fix tuple size check in std/jsonutils (#20637)
* Add test for tuple being invalid size * Test tuple size before accessing fields * Fix formatting for import * Fix not being able to build from csources_v1 Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
parent
98b2838a30
commit
d261135c5c
2 changed files with 19 additions and 3 deletions
|
|
@ -410,6 +410,13 @@ template fn() =
|
|||
doAssert foo.c == 0
|
||||
doAssert foo.c0 == 42
|
||||
|
||||
|
||||
block testInvalidTupleLength:
|
||||
let json = parseJson("[0]")
|
||||
# Should raise ValueError instead of index error
|
||||
doAssertRaises(ValueError):
|
||||
discard json.jsonTo((int, int))
|
||||
|
||||
type
|
||||
InnerEnum = enum
|
||||
A
|
||||
|
|
@ -431,7 +438,6 @@ template fn() =
|
|||
let json = inner.toJson(ToJsonOptions(enumMode: joptEnumSymbol))
|
||||
doAssert $json == """{"x":"hello","y":"A"}"""
|
||||
|
||||
|
||||
when false:
|
||||
## TODO: Implement support for nested variant objects allowing the tests
|
||||
## bellow to pass.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue