Skip to content

Commit

Permalink
Definitions required for client (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjq4214 authored Sep 25, 2022
1 parent a1bdcfa commit 43258f9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions byteseq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func Test_EqualFold(t *testing.T) {
}

for _, tc := range testCases {
res := EqualFold[string](tc.S1, tc.S2)
res := EqualFold(tc.S1, tc.S2)
require.Equal(t, tc.Expected, res, "string")

res = EqualFold[[]byte]([]byte(tc.S1), []byte(tc.S2))
res = EqualFold([]byte(tc.S1), []byte(tc.S2))
require.Equal(t, tc.Expected, res, "bytes")
}
}
5 changes: 5 additions & 0 deletions xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ package utils

// XMLMarshal returns the XML encoding of v.
type XMLMarshal func(v any) ([]byte, error)

// XMLUnmarshal parses the XML-encoded data and stores the result
// in the value pointed to by v. If v is nil or not a pointer,
// Unmarshal returns an InvalidUnmarshalError.
type XMLUnmarshal func(data []byte, v any) error
17 changes: 17 additions & 0 deletions xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,20 @@ func Test_DefaultXMLEncoder(t *testing.T) {

require.Equal(t, string(raw), xmlString)
}

func Test_DefaultXMLDecoder(t *testing.T) {
t.Parallel()

var (
ss serversXMLStructure
xmlBytes = []byte(xmlString)
xmlDecoder XMLUnmarshal = xml.Unmarshal
)

err := xmlDecoder(xmlBytes, &ss)
require.Nil(t, err)
require.Equal(t, 2, len(ss.Servers))
require.Equal(t, "1", ss.Version)
require.Equal(t, "fiber one", ss.Servers[0].Name)
require.Equal(t, "fiber two", ss.Servers[1].Name)
}

0 comments on commit 43258f9

Please sign in to comment.