-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ns_test.go
49 lines (43 loc) · 867 Bytes
/
ns_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
// Copyright 2020 The Mellium Contributors.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.
package clarkns_test
import (
"encoding/xml"
"errors"
"strconv"
"testing"
"mellium.im/clarkns"
)
var nsTests = [...]struct {
s string
name xml.Name
err error
}{
0: {},
1: {
s: "{foo}bar",
name: xml.Name{Space: "foo", Local: "bar"},
},
2: {
s: "bar",
name: xml.Name{Local: "bar"},
},
3: {
s: "{foo",
err: clarkns.ErrUnclosedNS,
},
}
func TestNS(t *testing.T) {
for i, tc := range nsTests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
name, err := clarkns.Name(tc.s)
if !errors.Is(err, tc.err) {
t.Errorf("wrong error: want=%v, got=%v", tc.err, err)
}
if tc.name != name {
t.Errorf("wrong namespace: want=%v, got=%v", tc.name, name)
}
})
}
}