| 446 | } |
| 447 | |
| 448 | func TestUnnecessaryEscapeOutputValue(t *testing.T) { |
| 449 | data := `<?xml version="1.0" encoding="utf-8"?> |
| 450 | <class_list xml:space="preserve"> |
| 451 | <student> |
| 452 | <name> Robert </name> |
| 453 | <grade>A+</grade> |
| 454 | |
| 455 | </student> |
| 456 | </class_list>` |
| 457 | |
| 458 | root, err := Parse(strings.NewReader(data)) |
| 459 | if err != nil { |
| 460 | t.Error(err) |
| 461 | } |
| 462 | |
| 463 | escapedInnerText := root.OutputXML(true) |
| 464 | if strings.Contains(escapedInnerText, "	") { |
| 465 | t.Fatal("\\n has been escaped unnecessarily") |
| 466 | } |
| 467 | |
| 468 | if strings.Contains(escapedInnerText, "
") { |
| 469 | t.Fatal("\\t has been escaped unnecessarily") |
| 470 | } |
| 471 | |
| 472 | } |
| 473 | |
| 474 | func TestUnnecessaryEscapeValueWrite(t *testing.T) { |
| 475 | data := `<?xml version="1.0" encoding="utf-8"?> |