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

Function TestUnnecessaryEscapeValueWrite

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

Source from the content-addressed store, hash-verified

472}
473
474func TestUnnecessaryEscapeValueWrite(t *testing.T) {
475 data := `<?xml version="1.0" encoding="utf-8"?>
476 <class_list xml:space="preserve">
477 <student>
478 <name> Robert </name>
479 <grade>A+</grade>
480
481 </student>
482 </class_list>`
483
484 root, err := Parse(strings.NewReader(data))
485 if err != nil {
486 t.Error(err)
487 }
488
489 var b strings.Builder
490 err = root.Write(&b, true)
491 testTrue(t, err == nil)
492 escapedInnerText := b.String()
493 if strings.Contains(escapedInnerText, "&#x9") {
494 t.Fatal("\\n has been escaped unnecessarily")
495 }
496
497 if strings.Contains(escapedInnerText, "&#xA") {
498 t.Fatal("\\t has been escaped unnecessarily")
499 }
500
501}
502
503func TestHtmlUnescapeStringOriginString(t *testing.T) {
504 // has escape html character and \t

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…