mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +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,46 +0,0 @@
|
|||
import json
|
||||
|
||||
pub struct DocumentFindFilter[T] {
|
||||
pub:
|
||||
selector ?T
|
||||
selector2 ?[]T
|
||||
selector3 ?[1]T
|
||||
limit ?int
|
||||
skip ?int
|
||||
fields ?[]string // This breaks the compiler when encoding to JSON
|
||||
conflicts ?bool
|
||||
read_quorum ?int @[json: r]
|
||||
update ?bool
|
||||
stable ?bool
|
||||
stale ?string
|
||||
execution_stats ?bool
|
||||
}
|
||||
|
||||
fn test_string() {
|
||||
t := DocumentFindFilter[string]{
|
||||
selector: 'aa'
|
||||
selector2: ['a', 'b']
|
||||
selector3: ['z']!
|
||||
}
|
||||
|
||||
assert json.encode(t) == '{"selector":"aa","selector2":["a","b"],"selector3":["z"]}'
|
||||
assert json.decode(DocumentFindFilter[string], '{"selector":"aa","selector2":["a","b"],"selector3":["z"]}')! == t
|
||||
}
|
||||
|
||||
fn test_int() ! {
|
||||
t := DocumentFindFilter[int]{
|
||||
selector: 1
|
||||
selector2: [1, 2]
|
||||
selector3: [3]!
|
||||
}
|
||||
|
||||
assert json.encode(t) == '{"selector":1,"selector2":[1,2],"selector3":[3]}'
|
||||
assert json.decode(DocumentFindFilter[int], '{"selector":1,"selector2":[1,2],"selector3":[3]}')! == t
|
||||
}
|
||||
|
||||
fn test_none() ! {
|
||||
t := DocumentFindFilter[int]{}
|
||||
|
||||
assert json.encode(t) == '{}'
|
||||
assert json.decode(DocumentFindFilter[int], '{}')! == t
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue