Skip to content

Commit

Permalink
yet more reflect tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wkhere committed Sep 14, 2023
1 parent 1fcd347 commit 4bd8e2f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ type S struct {
X int
}

type S2 struct {
Name string
X int `bcl:"y"`
}

var reflectTab = []reflecttc{
rvalid(``, &rr{}, &rr{}),

Expand Down Expand Up @@ -98,8 +103,10 @@ var reflectTab = []reflecttc{

rerror(``, []S{}, "expected pointer to a slice of structs"),

rvalid(`s "foo"{x=10}`, &[]S{}, &[]S{{Name: "foo", X: 10}}),
rerror(`y "foo"{x=10}`, &[]S{}, "mismatch: struct type S, block type y"),
rvalid(`s "foo"{x=1}`, &[]S{}, &[]S{{Name: "foo", X: 1}}),
rerror(`y "foo"{x=1}`, &[]S{}, "mismatch: struct type S, block type y"),
rerror(`s "foo"{y=1}`, &[]S{}, `field mapping for "y" not found in struct`),
rvalid(`s2 "foo"{y=1}`, &[]S2{}, &[]S2{{Name: "foo", X: 1}}),
rerror(`s "foo"{x=""}`, &[]S{},
"type mismatch.+ struct.X has int, block.x has string",
),
Expand Down

0 comments on commit 4bd8e2f

Please sign in to comment.