Skip to content

Commit

Permalink
refine struct test
Browse files Browse the repository at this point in the history
  • Loading branch information
hyorigo committed Jan 12, 2024
1 parent cf8b374 commit eee7c64
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion convert/value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,14 @@ func TestGoTypeWrapperValue(t *testing.T) {
}
}

type mockStr struct{}

func (m mockStr) String() string { return "mock-str" }

func TestMakeDictWithTag(t *testing.T) {
var fsr fmt.Stringer
var fsr, fsr2 fmt.Stringer
ms := mockStr{}
fsr2 = ms
type contact struct {
Name string `sl:"name"`
Street string `sl:"address,omitempty"`
Expand Down Expand Up @@ -1003,6 +1009,7 @@ assert.Eq(dir(a), ["Name", "Street"])
"A": &contact{Name: "bob", Street: "oak"},
"R": strings.NewReader("hello"),
"S": fsr,
"T": fsr2,
},
customTag: `sl`,
codeSnippet: `
Expand All @@ -1019,6 +1026,9 @@ assert.Eq(type(r), "starlight_struct<*strings.Reader>")
s = data["S"]
assert.Eq(type(s), "starlight_interface<<nil>>")
t = data["T"]
assert.Eq(type(t), "starlight_struct<convert_test.mockStr>")
`,
},
{
Expand Down

0 comments on commit eee7c64

Please sign in to comment.