2023-01-09 09:36:45 +03:00
|
|
|
import json
|
2022-12-10 19:44:20 +03:00
|
|
|
|
2023-01-09 09:36:45 +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
|
|
|
|
2023-01-09 09:36:45 +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
|
|
|
|
2023-01-09 09:36:45 +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
|
|
|
|
}
|
|
|
|
|
2023-01-09 09:36:45 +03:00
|
|
|
fn test_option_array() {
|
2022-12-10 19:44:20 +03:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_alias() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2023-01-09 09:36:45 +03:00
|
|
|
fn test_option_alias() {
|
2022-12-10 19:44:20 +03:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_sumtypes() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2023-01-09 09:36:45 +03:00
|
|
|
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
|
2023-01-09 09:36:45 +03:00
|
|
|
}
|