...
1 package mxj
2
3 import "testing"
4
5 var whiteSpaceDataSeqTest = []byte(`<books>
6 <book seq="1" ser="5">
7 <author>William T. Gaddis </author>
8 <title> The Recognitions </title>
9 <review> One of the great seminal American novels of the 20th century.</review>
10 </book>
11 <book seq="2">
12 <author>Austin Tappan Wright</author>
13 <title>Islandia</title>
14 <review>An example of earlier 20th century American utopian fiction.</review>
15 </book>
16 <book seq="3" ser="6">
17 <author> John Hawkes </author>
18 <title> The Beetle Leg </title>
19 <review> A lyrical novel about the construction of Ft. Peck Dam in Montana. </review>
20 </book>
21 </books>`)
22
23 func TestNewMapXmlSeqWhiteSpace(t *testing.T) {
24 t.Run("Testing NewMapFormattedXmlSeq with WhiteSpacing", func(t *testing.T) {
25 DisableTrimWhiteSpace(true)
26
27 m, err := NewMapFormattedXmlSeq(whiteSpaceDataSeqTest)
28 if err != nil {
29 t.Fatal(err)
30 }
31
32 m1 := MapSeq(m)
33 x, err := m1.XmlIndent("", " ")
34 if err != nil {
35 t.Fatal(err)
36 }
37
38 if string(x) != string(whiteSpaceDataSeqTest) {
39 t.Fatalf("expected\n'%s' \ngot \n'%s'", whiteSpaceDataSeqTest, x)
40 }
41 })
42 DisableTrimWhiteSpace(false)
43 }
44
View as plain text