MCPcopy Create free account
hub / github.com/antchfx/xpath / TestNodeType

Function TestNodeType

xpath_test.go:266–287  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

264}
265
266func TestNodeType(t *testing.T) {
267 tests := []struct {
268 expr string
269 expected NodeType
270 }{
271 {`//employee`, ElementNode},
272 {`//name[text()]`, ElementNode},
273 {`//name/text()`, TextNode},
274 {`//employee/@id`, AttributeNode},
275 }
276 for _, test := range tests {
277 v := selectNode(employee_example, test.expr)
278 assertTrue(t, v != nil)
279 assertEqual(t, test.expected, v.Type)
280 }
281
282 doc := createNode("", RootNode)
283 doc.createChildNode("<!-- This is a comment -->", CommentNode)
284 n := selectNode(doc, "//comment()")
285 assertTrue(t, n != nil)
286 assertEqual(t, CommentNode, n.Type)
287}
288
289func iterateNavs(t *NodeIterator) []*TNodeNavigator {
290 var nodes []*TNodeNavigator

Callers

nothing calls this directly

Calls 5

selectNodeFunction · 0.85
assertTrueFunction · 0.85
assertEqualFunction · 0.85
createNodeFunction · 0.85
createChildNodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…