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

Function TestTooNested

parse_test.go:331–372  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

329}
330
331func TestTooNested(t *testing.T) {
332 s := `<?xml version="1.0" encoding="UTF-8"?>
333 <!-- comment here-->
334 <AAA>
335 <BBB>
336 <DDD>
337 <CCC>
338 <DDD/>
339 <EEE/>
340 </CCC>
341 </DDD>
342 </BBB>
343 <CCC>
344 <DDD>
345 <EEE>
346 <DDD>
347 <FFF/>
348 </DDD>
349 </EEE>
350 </DDD>
351 </CCC>
352 </AAA>`
353 root, err := Parse(strings.NewReader(s))
354 if err != nil {
355 t.Error(err)
356 }
357 aaa := findNode(root, "AAA")
358 if aaa == nil {
359 t.Fatal("AAA node not exists")
360 }
361 ccc := aaa.LastChild.PrevSibling
362 if ccc.Data != "CCC" {
363 t.Fatalf("expected node is CCC,but got %s", ccc.Data)
364 }
365 bbb := ccc.PrevSibling.PrevSibling
366 if bbb.Data != "BBB" {
367 t.Fatalf("expected node is bbb,but got %s", bbb.Data)
368 }
369 ddd := findNode(bbb, "DDD")
370 testNode(t, ddd, "DDD")
371 testNode(t, ddd.LastChild.PrevSibling, "CCC")
372}
373
374func TestAttributeWithNamespace(t *testing.T) {
375 s := `<?xml version="1.0" encoding="UTF-8"?><root xmlns:n1="http://www.w3.org">

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.85
findNodeFunction · 0.85
testNodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…