(t *testing.T)
| 632 | } |
| 633 | |
| 634 | func TestOutputXMLWithSpaceDirect(t *testing.T) { |
| 635 | s := `<?xml version="1.0" encoding="utf-8"?> |
| 636 | <class_list> |
| 637 | <student> |
| 638 | <name xml:space="preserve"> Robert </name> |
| 639 | <grade>A+</grade> |
| 640 | </student> |
| 641 | </class_list>` |
| 642 | doc, _ := Parse(strings.NewReader(s)) |
| 643 | t.Log(doc.OutputXML(true)) |
| 644 | |
| 645 | n := FindOne(doc, "/class_list/student/name") |
| 646 | expected := `<name xml:space="preserve"> Robert </name>` |
| 647 | if g := doc.OutputXML(false); !strings.Contains(g, expected) { |
| 648 | t.Errorf(`expected "%s", obtained "%s"`, expected, g) |
| 649 | } |
| 650 | |
| 651 | output := html.UnescapeString(doc.OutputXMLWithOptions(WithOutputSelf(), WithoutPreserveSpace())) |
| 652 | if strings.Contains(output, "\n") { |
| 653 | t.Errorf("the outputted xml contains newlines") |
| 654 | } |
| 655 | t.Log(n.OutputXML(false)) |
| 656 | } |
| 657 | |
| 658 | func TestOutputXMLWithSpaceOverwrittenToPreserve(t *testing.T) { |
| 659 | s := `<?xml version="1.0" encoding="utf-8"?> |
nothing calls this directly
no test coverage detected
searching dependent graphs…