mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
json: move _test.v
files to vlib/json/tests/
(#22731)
This commit is contained in:
parent
9de84888b3
commit
8ebbacecd6
37 changed files with 1 additions and 1 deletions
|
@ -1,40 +0,0 @@
|
|||
import json
|
||||
|
||||
struct Test {
|
||||
field MySumType
|
||||
}
|
||||
|
||||
type MyInt = int
|
||||
type MyString = string
|
||||
type MySumType = MyString | int | string
|
||||
|
||||
fn test_alias_to_primitive() {
|
||||
mut test := Test{
|
||||
field: MyString('foo')
|
||||
}
|
||||
mut encoded := json.encode(test)
|
||||
assert dump(encoded) == '{"field":"foo"}'
|
||||
assert json.decode(Test, '{"field": "foo"}')!.field == MySumType('foo')
|
||||
|
||||
test = Test{
|
||||
field: 'foo'
|
||||
}
|
||||
encoded = json.encode(test)
|
||||
assert dump(encoded) == '{"field":"foo"}'
|
||||
assert json.decode(Test, '{"field":"foo"}')! == test
|
||||
|
||||
test = Test{
|
||||
field: 1
|
||||
}
|
||||
encoded = json.encode(test)
|
||||
assert dump(encoded) == '{"field":1}'
|
||||
assert json.decode(Test, '{"field":1}')! == test
|
||||
|
||||
mut test2 := MyString('foo')
|
||||
encoded = json.encode(test2)
|
||||
assert dump(encoded) == '"foo"'
|
||||
|
||||
mut test3 := MyInt(1000)
|
||||
encoded = json.encode(test3)
|
||||
assert dump(encoded) == '1000'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue