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

Function TestHtmlUnescapeStringOriginStringWrite

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

Source from the content-addressed store, hash-verified

522}
523
524func TestHtmlUnescapeStringOriginStringWrite(t *testing.T) {
525 // has escape html character and \t
526 data := `<?xml version="1.0" encoding="utf-8"?>
527 <example xml:space="preserve"><word>&amp;#48; </word></example>`
528
529 root, err := Parse(strings.NewReader(data))
530 if err != nil {
531 t.Error(err)
532 }
533
534 var b strings.Builder
535 err = root.Write(&b, false)
536 testTrue(t, err == nil)
537 escapedInnerText := b.String()
538 unescapeString := html.UnescapeString(escapedInnerText)
539 if strings.Contains(unescapeString, "&amp;") {
540 t.Fatal("&amp; need unescape")
541 }
542 if !strings.Contains(escapedInnerText, "&amp;#48;\t\t") {
543 t.Fatal("Inner Text should keep plain text")
544 }
545
546}
547
548func TestOutputXMLWithNamespacePrefix(t *testing.T) {
549 s := `<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body></S:Body></S:Envelope>`

Callers

nothing calls this directly

Calls 4

ParseFunction · 0.85
testTrueFunction · 0.85
WriteMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…