| 1 | import json |
| 2 | |
| 3 | fn test_option_types() { |
| 4 | assert json.decode[StructTypeOption[string]]('{}')!.val == none |
| 5 | assert json.decode[StructTypeOption[string]]('{"val": ""}')!.val == '' |
| 6 | assert json.decode[StructTypeOption[string]]('{"val": "0"}')!.val == '0' |
| 7 | assert json.decode[StructTypeOption[string]]('{"val": "1"}')!.val == '1' |
| 8 | assert json.decode[StructTypeOption[string]]('{"val": "2"}')!.val == '2' |
| 9 | assert json.decode[StructTypeOption[string]]('{"val": 0}')!.val == '0' |
| 10 | assert json.decode[StructTypeOption[string]]('{"val": 1}')!.val == '1' |
| 11 | assert json.decode[StructTypeOption[string]]('{"val": 2}')!.val == '2' |
| 12 | assert json.decode[StructTypeOption[string]]('{"val": "true"}')!.val == 'true' |
| 13 | assert json.decode[StructTypeOption[string]]('{"val": "false"}')!.val == 'false' |
| 14 | assert json.decode[StructTypeOption[string]]('{"val": true}')!.val == 'true' |
| 15 | assert json.decode[StructTypeOption[string]]('{"val": false}')!.val == 'false' |
| 16 | |
| 17 | assert json.decode[StructTypeOption[bool]]('{}')!.val == none |
| 18 | assert json.decode[StructTypeOption[bool]]('{"val": ""}')!.val == false |
| 19 | assert json.decode[StructTypeOption[bool]]('{"val": "0"}')!.val == false |
| 20 | assert json.decode[StructTypeOption[bool]]('{"val": "1"}')!.val == true |
| 21 | assert json.decode[StructTypeOption[bool]]('{"val": "2"}')!.val == true |
| 22 | assert json.decode[StructTypeOption[bool]]('{"val": 0}')!.val == false |
| 23 | assert json.decode[StructTypeOption[bool]]('{"val": 1}')!.val == true |
| 24 | assert json.decode[StructTypeOption[bool]]('{"val": 2}')!.val == true |
| 25 | assert json.decode[StructTypeOption[bool]]('{"val": "true"}')!.val == true |
| 26 | assert json.decode[StructTypeOption[bool]]('{"val": "false"}')!.val == false |
| 27 | assert json.decode[StructTypeOption[bool]]('{"val": true}')!.val == true |
| 28 | assert json.decode[StructTypeOption[bool]]('{"val": false}')!.val == false |
| 29 | |
| 30 | assert json.decode[StructTypeOption[int]]('{}')!.val == none |
| 31 | assert json.decode[StructTypeOption[int]]('{"val": ""}')!.val == 0 |
| 32 | assert json.decode[StructTypeOption[int]]('{"val": "0"}')!.val == 0 |
| 33 | assert json.decode[StructTypeOption[int]]('{"val": "1"}')!.val == 1 |
| 34 | assert json.decode[StructTypeOption[int]]('{"val": "2"}')!.val == 2 |
| 35 | assert json.decode[StructTypeOption[int]]('{"val": 0}')!.val == 0 |
| 36 | assert json.decode[StructTypeOption[int]]('{"val": 1}')!.val == 1 |
| 37 | assert json.decode[StructTypeOption[int]]('{"val": 2}')!.val == 2 |
| 38 | assert json.decode[StructTypeOption[int]]('{"val": "true"}')!.val == 1 |
| 39 | assert json.decode[StructTypeOption[int]]('{"val": "false"}')!.val == 0 |
| 40 | assert json.decode[StructTypeOption[int]]('{"val": true}')!.val == 1 |
| 41 | assert json.decode[StructTypeOption[int]]('{"val": false}')!.val == 0 |
| 42 | } |
| 43 | |
| 44 | fn test_array() { |
| 45 | // TODO |
| 46 | } |
| 47 | |
| 48 | fn test_option_array() { |
| 49 | // TODO |
| 50 | } |
| 51 | |
| 52 | fn test_alias() { |
| 53 | // TODO |
| 54 | } |
| 55 | |
| 56 | fn test_option_alias() { |
| 57 | // TODO |
| 58 | } |
| 59 | |
| 60 | fn test_sumtypes() { |
| 61 | // TODO |
| 62 | } |
| 63 | |
| 64 | fn test_option_sumtypes() { |
| 65 | // TODO |
| 66 | } |
| 67 | |
| 68 | fn test_pointer() { |
| 69 | // TODO |
| 70 | } |
| 71 | |
| 72 | fn test_caos() { |
| 73 | // TODO |
| 74 | } |
| 75 | |
| 76 | fn test_caos_array() { |
| 77 | // TODO |
| 78 | } |
| 79 | |