mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
x/json2: fix decoder errors (#13655)
* x/json2: fix decoder errors, refactoring * x/json2: add error-catching tests * x/json2: add missing docs * x/json2: fmt
This commit is contained in:
@@ -66,3 +66,19 @@ fn test_nested_array_object() ? {
|
||||
decoded := parser.decode() ?
|
||||
assert parser.n_level == 0
|
||||
}
|
||||
|
||||
fn test_raw_decode_map_invalid() ? {
|
||||
raw_decode('{"name","Bob","age":20}') or {
|
||||
assert err.msg() == '[x.json2] invalid token `comma`, expecting `colon` (0:5)'
|
||||
return
|
||||
}
|
||||
assert false
|
||||
}
|
||||
|
||||
fn test_raw_decode_array_invalid() ? {
|
||||
raw_decode('["Foo", 1,}') or {
|
||||
assert err.msg() == '[x.json2] invalid token `rcbr` (0:5)'
|
||||
return
|
||||
}
|
||||
assert false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user