1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/x/json2/decode_struct_todo_test.vv

79 lines
2.9 KiB
V
Raw Normal View History

import json
2022-12-10 19:44:20 +03:00
fn test_option_types() {
assert json.decode[StructTypeOption[string]]('{}')!.val == none
assert json.decode[StructTypeOption[string]]('{"val": ""}')!.val == ''
assert json.decode[StructTypeOption[string]]('{"val": "0"}')!.val == '0'
assert json.decode[StructTypeOption[string]]('{"val": "1"}')!.val == '1'
assert json.decode[StructTypeOption[string]]('{"val": "2"}')!.val == '2'
assert json.decode[StructTypeOption[string]]('{"val": 0}')!.val == '0'
assert json.decode[StructTypeOption[string]]('{"val": 1}')!.val == '1'
assert json.decode[StructTypeOption[string]]('{"val": 2}')!.val == '2'
assert json.decode[StructTypeOption[string]]('{"val": "true"}')!.val == 'true'
assert json.decode[StructTypeOption[string]]('{"val": "false"}')!.val == 'false'
assert json.decode[StructTypeOption[string]]('{"val": true}')!.val == 'true'
assert json.decode[StructTypeOption[string]]('{"val": false}')!.val == 'false'
2022-12-10 19:44:20 +03:00
assert json.decode[StructTypeOption[bool]]('{}')!.val == none
assert json.decode[StructTypeOption[bool]]('{"val": ""}')!.val == false
assert json.decode[StructTypeOption[bool]]('{"val": "0"}')!.val == false
assert json.decode[StructTypeOption[bool]]('{"val": "1"}')!.val == true
assert json.decode[StructTypeOption[bool]]('{"val": "2"}')!.val == true
assert json.decode[StructTypeOption[bool]]('{"val": 0}')!.val == false
assert json.decode[StructTypeOption[bool]]('{"val": 1}')!.val == true
assert json.decode[StructTypeOption[bool]]('{"val": 2}')!.val == true
assert json.decode[StructTypeOption[bool]]('{"val": "true"}')!.val == true
assert json.decode[StructTypeOption[bool]]('{"val": "false"}')!.val == false
assert json.decode[StructTypeOption[bool]]('{"val": true}')!.val == true
assert json.decode[StructTypeOption[bool]]('{"val": false}')!.val == false
2022-12-10 19:44:20 +03:00
assert json.decode[StructTypeOption[int]]('{}')!.val == none
assert json.decode[StructTypeOption[int]]('{"val": ""}')!.val == 0
assert json.decode[StructTypeOption[int]]('{"val": "0"}')!.val == 0
assert json.decode[StructTypeOption[int]]('{"val": "1"}')!.val == 1
assert json.decode[StructTypeOption[int]]('{"val": "2"}')!.val == 2
assert json.decode[StructTypeOption[int]]('{"val": 0}')!.val == 0
assert json.decode[StructTypeOption[int]]('{"val": 1}')!.val == 1
assert json.decode[StructTypeOption[int]]('{"val": 2}')!.val == 2
assert json.decode[StructTypeOption[int]]('{"val": "true"}')!.val == 1
assert json.decode[StructTypeOption[int]]('{"val": "false"}')!.val == 0
assert json.decode[StructTypeOption[int]]('{"val": true}')!.val == 1
assert json.decode[StructTypeOption[int]]('{"val": false}')!.val == 0
2022-12-10 19:44:20 +03:00
}
fn test_array() {
// TODO
}
fn test_option_array() {
2022-12-10 19:44:20 +03:00
// TODO
}
fn test_alias() {
// TODO
}
fn test_option_alias() {
2022-12-10 19:44:20 +03:00
// TODO
}
fn test_sumtypes() {
// TODO
}
fn test_option_sumtypes() {
2022-12-10 19:44:20 +03:00
// TODO
}
fn test_pointer() {
// TODO
}
fn test_caos() {
// TODO
}
fn test_caos_array() {
// TODO
}