MCPcopy Create free account
hub / github.com/antchfx/xmlquery / TestNavigator

Function TestNavigator

query_test.go:106–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

104}
105
106func TestNavigator(t *testing.T) {
107 nav := &NodeNavigator{curr: doc, root: doc, attr: -1}
108 nav.MoveToChild() // New Line
109 nav.MoveToNext() // catalog
110 if nav.curr.Data != "catalog" {
111 t.Fatal("current node name != `catalog`")
112 }
113 nav.MoveToChild() // New Line
114 nav.MoveToNext() // comment node
115 if nav.curr.Type != CommentNode {
116 t.Fatal("node type not CommentNode")
117 }
118 nav.Value()
119 nav.MoveToNext() //book
120 nav.MoveToChild()
121 nav.MoveToNext() // book/author
122 if nav.LocalName() != "author" {
123 t.Fatalf("node error")
124 }
125 nav.MoveToParent() // book
126 nav.MoveToNext() // next book
127 if nav.curr.SelectAttr("id") != "bk102" {
128 t.Fatal("node error")
129 }
130}
131
132func TestAttributesNamespaces(t *testing.T) {
133 doc := loadXML(`

Callers

nothing calls this directly

Calls 6

MoveToChildMethod · 0.95
MoveToNextMethod · 0.95
ValueMethod · 0.95
LocalNameMethod · 0.95
MoveToParentMethod · 0.95
SelectAttrMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…