-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelement_test.go
More file actions
37 lines (32 loc) · 835 Bytes
/
Copy pathelement_test.go
File metadata and controls
37 lines (32 loc) · 835 Bytes
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
package libxml_test
import (
"reflect"
"testing"
"github.com/amarin/libxml"
)
func TestElement_Tag(t *testing.T) {
for _, tt := range []struct {
name string
path string
names []libxml.TagName
}{
{"1st_level", "/first", []libxml.TagName{"first"}},
{"2nd_level", "/first/second", []libxml.TagName{"first", "second"}},
{"3rd_level", "/first/second/third", []libxml.TagName{"first", "second", "third"}},
} {
tt := tt // pin tt
t.Run(tt.name, func(t *testing.T) {
tt := tt // pin tt
root := libxml.MakeElement(nil, "", nil, nil, nil)
got := root.Tag(tt.names...)
path := got.Path()
if path != tt.path {
t.Errorf("Tag() = %v, want %v", path, tt.path)
}
got1 := root.Tag(tt.names...)
if !reflect.DeepEqual(got, got1) {
t.Errorf("Tag() = \n%v, same \n%v", got, got1)
}
})
}
}