mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
79 lines
2.9 KiB
V
79 lines
2.9 KiB
V
import json
|
|
|
|
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'
|
|
|
|
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
|
|
|
|
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
|
|
}
|
|
|
|
fn test_array() {
|
|
// TODO
|
|
}
|
|
|
|
fn test_option_array() {
|
|
// TODO
|
|
}
|
|
|
|
fn test_alias() {
|
|
// TODO
|
|
}
|
|
|
|
fn test_option_alias() {
|
|
// TODO
|
|
}
|
|
|
|
fn test_sumtypes() {
|
|
// TODO
|
|
}
|
|
|
|
fn test_option_sumtypes() {
|
|
// TODO
|
|
}
|
|
|
|
fn test_pointer() {
|
|
// TODO
|
|
}
|
|
|
|
fn test_caos() {
|
|
// TODO
|
|
}
|
|
|
|
fn test_caos_array() {
|
|
// TODO
|
|
}
|