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

77 lines
2.9 KiB
V
Raw Normal View History

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