-
Notifications
You must be signed in to change notification settings - Fork 0
/
xml_test.go
58 lines (52 loc) · 1.02 KB
/
xml_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package epplib
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestString(t *testing.T) {
str := XMLString("&")
assert.Equal(t, "&", str.String())
str = "hello"
assert.Equal(t, "hello", str.String())
}
func TestParseBool(t *testing.T) {
for _, tc := range []struct {
name string
input string
expectError bool
expectBool bool
}{
{
name: "can parse 1",
input: "1",
expectBool: true,
},
{
name: "can parse 0",
input: "0",
expectBool: false,
},
{
name: "can parse true",
input: "true",
expectBool: true,
},
{
name: "can parse false",
input: "false",
expectBool: false,
},
{
name: "can't parse unknown",
input: "uknown",
expectError: true,
},
} {
t.Run(tc.name, func(t *testing.T) {
gotBool, gotErr := ParseXMLBool(tc.input)
require.Equal(t, tc.expectError, gotErr != nil)
assert.Equal(t, tc.expectBool, gotBool)
})
}
}