-
Notifications
You must be signed in to change notification settings - Fork 113
/
xml3_test.go
72 lines (64 loc) · 1.51 KB
/
xml3_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// xml3_test.go - patch tests
package mxj
import (
"fmt"
"testing"
)
func TestXml3(t *testing.T) {
fmt.Println("\n------------ xml3_test.go")
}
// for: https://github.com/clbanning/mxj/pull/26
func TestOnlyAttributes(t *testing.T) {
fmt.Println("========== TestOnlyAttributes")
dom, err := NewMapXml([]byte(`
<memballoon model="virtio">
<address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
<empty/>
</memballoon>)`))
if err != nil {
t.Fatal(err)
}
xml, err := dom.XmlIndent("", " ")
if err != nil {
t.Fatal(err)
}
fmt.Println(string(xml))
}
func TestOnlyAttributesSeq(t *testing.T) {
fmt.Println("========== TestOnlyAttributesSeq")
dom, err := NewMapXmlSeq([]byte(`
<memballoon model="virtio">
<address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
<empty/>
</memballoon>)`))
if err != nil {
t.Fatal(err)
}
xml, err := dom.XmlIndent("", " ")
if err != nil {
t.Fatal(err)
}
fmt.Println(string(xml))
}
func TestDecodeSimpleValuesAsMap(t *testing.T) {
fmt.Println("========== TestDecodeSimpleValuesAsMap")
DecodeSimpleValuesAsMap()
xml := `<item>
<id>30102</id>
<title>Mini Drone Inteligente - Branco</title>
<price unit="BRL">149.90</price>
</item>`
m, err := NewMapXml([]byte(xml))
if err != nil {
t.Fatal(err)
}
fmt.Println("xml:", string(xml))
fmt.Printf("m : %v\n", m)
fmt.Println("========== (default)")
DecodeSimpleValuesAsMap()
m, err = NewMapXml([]byte(xml))
if err != nil {
t.Fatal(err)
}
fmt.Printf("m : %v\n", m)
}