Skip to content

Commit 43258f9

Browse files
authored
Definitions required for client (#29)
1 parent a1bdcfa commit 43258f9

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

byteseq_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ func Test_EqualFold(t *testing.T) {
6161
}
6262

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

67-
res = EqualFold[[]byte]([]byte(tc.S1), []byte(tc.S2))
67+
res = EqualFold([]byte(tc.S1), []byte(tc.S2))
6868
require.Equal(t, tc.Expected, res, "bytes")
6969
}
7070
}

xml.go

+5
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ package utils
22

33
// XMLMarshal returns the XML encoding of v.
44
type XMLMarshal func(v any) ([]byte, error)
5+
6+
// XMLUnmarshal parses the XML-encoded data and stores the result
7+
// in the value pointed to by v. If v is nil or not a pointer,
8+
// Unmarshal returns an InvalidUnmarshalError.
9+
type XMLUnmarshal func(data []byte, v any) error

xml_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,20 @@ func Test_DefaultXMLEncoder(t *testing.T) {
5959

6060
require.Equal(t, string(raw), xmlString)
6161
}
62+
63+
func Test_DefaultXMLDecoder(t *testing.T) {
64+
t.Parallel()
65+
66+
var (
67+
ss serversXMLStructure
68+
xmlBytes = []byte(xmlString)
69+
xmlDecoder XMLUnmarshal = xml.Unmarshal
70+
)
71+
72+
err := xmlDecoder(xmlBytes, &ss)
73+
require.Nil(t, err)
74+
require.Equal(t, 2, len(ss.Servers))
75+
require.Equal(t, "1", ss.Version)
76+
require.Equal(t, "fiber one", ss.Servers[0].Name)
77+
require.Equal(t, "fiber two", ss.Servers[1].Name)
78+
}

0 commit comments

Comments
 (0)