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

Function TestHtmlUnescapeStringOriginString

node_test.go:503–522  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

501}
502
503func TestHtmlUnescapeStringOriginString(t *testing.T) {
504 // has escape html character and \t
505 data := `<?xml version="1.0" encoding="utf-8"?>
506 <example xml:space="preserve"><word>&amp;#48; </word></example>`
507
508 root, err := Parse(strings.NewReader(data))
509 if err != nil {
510 t.Error(err)
511 }
512
513 escapedInnerText := root.OutputXML(false)
514 unescapeString := html.UnescapeString(escapedInnerText)
515 if strings.Contains(unescapeString, "&amp;") {
516 t.Fatal("&amp; need unescape")
517 }
518 if !strings.Contains(escapedInnerText, "&amp;#48;\t\t") {
519 t.Fatal("Inner Text should keep plain text")
520 }
521
522}
523
524func TestHtmlUnescapeStringOriginStringWrite(t *testing.T) {
525 // has escape html character and \t

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.85
OutputXMLMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…