Making the recursive SelectNodes a separate function and adding tests
This commit is contained in:
parent
05fda09c14
commit
0459b7b32e
3 changed files with 43 additions and 5 deletions
18
xmlx_test.go
18
xmlx_test.go
|
@ -31,7 +31,23 @@ func TestWildcard(t *testing.T) {
|
|||
list := doc.SelectNodes("ns", "*")
|
||||
|
||||
if len(list) != 1 {
|
||||
t.Errorf("Wrong number of child elements. Expected 4, got %d.", len(list))
|
||||
t.Errorf("Wrong number of child elements. Expected 1, got %d.", len(list))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestWildcardRecursive(t *testing.T) {
|
||||
doc := New()
|
||||
|
||||
if err := doc.LoadFile("test2.xml", nil); err != nil {
|
||||
t.Error(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
list := doc.SelectNodesRecursive("ns", "*")
|
||||
|
||||
if len(list) != 7 {
|
||||
t.Errorf("Wrong number of child elements. Expected 7, got %d.", len(list))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue