OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [encoding/] [xml/] [xml_test.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors.  All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package xml
6
 
7
import (
8
        "io"
9
        "reflect"
10
        "strings"
11
        "testing"
12
)
13
 
14
const testInput = `
15
16
17
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
18
19
        "\r\n\t" + `  >
20
  World <>'" 白鵬ç¿”
21
  
22
  
23
    
24
  
25
  
26
    
27
  
28
`
29
 
30
var rawTokens = []Token{
31
        CharData("\n"),
32
        ProcInst{"xml", []byte(`version="1.0" encoding="UTF-8"`)},
33
        CharData("\n"),
34
        Directive(`DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
35
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"`),
36
        CharData("\n"),
37
        StartElement{Name{"", "body"}, []Attr{{Name{"xmlns", "foo"}, "ns1"}, {Name{"", "xmlns"}, "ns2"}, {Name{"xmlns", "tag"}, "ns3"}}},
38
        CharData("\n  "),
39
        StartElement{Name{"", "hello"}, []Attr{{Name{"", "lang"}, "en"}}},
40
        CharData("World <>'\" 白鵬翔"),
41
        EndElement{Name{"", "hello"}},
42
        CharData("\n  "),
43
        StartElement{Name{"", "goodbye"}, []Attr{}},
44
        EndElement{Name{"", "goodbye"}},
45
        CharData("\n  "),
46
        StartElement{Name{"", "outer"}, []Attr{{Name{"foo", "attr"}, "value"}, {Name{"xmlns", "tag"}, "ns4"}}},
47
        CharData("\n    "),
48
        StartElement{Name{"", "inner"}, []Attr{}},
49
        EndElement{Name{"", "inner"}},
50
        CharData("\n  "),
51
        EndElement{Name{"", "outer"}},
52
        CharData("\n  "),
53
        StartElement{Name{"tag", "name"}, []Attr{}},
54
        CharData("\n    "),
55
        CharData("Some text here."),
56
        CharData("\n  "),
57
        EndElement{Name{"tag", "name"}},
58
        CharData("\n"),
59
        EndElement{Name{"", "body"}},
60
        Comment(" missing final newline "),
61
}
62
 
63
var cookedTokens = []Token{
64
        CharData("\n"),
65
        ProcInst{"xml", []byte(`version="1.0" encoding="UTF-8"`)},
66
        CharData("\n"),
67
        Directive(`DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
68
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"`),
69
        CharData("\n"),
70
        StartElement{Name{"ns2", "body"}, []Attr{{Name{"xmlns", "foo"}, "ns1"}, {Name{"", "xmlns"}, "ns2"}, {Name{"xmlns", "tag"}, "ns3"}}},
71
        CharData("\n  "),
72
        StartElement{Name{"ns2", "hello"}, []Attr{{Name{"", "lang"}, "en"}}},
73
        CharData("World <>'\" 白鵬翔"),
74
        EndElement{Name{"ns2", "hello"}},
75
        CharData("\n  "),
76
        StartElement{Name{"ns2", "goodbye"}, []Attr{}},
77
        EndElement{Name{"ns2", "goodbye"}},
78
        CharData("\n  "),
79
        StartElement{Name{"ns2", "outer"}, []Attr{{Name{"ns1", "attr"}, "value"}, {Name{"xmlns", "tag"}, "ns4"}}},
80
        CharData("\n    "),
81
        StartElement{Name{"ns2", "inner"}, []Attr{}},
82
        EndElement{Name{"ns2", "inner"}},
83
        CharData("\n  "),
84
        EndElement{Name{"ns2", "outer"}},
85
        CharData("\n  "),
86
        StartElement{Name{"ns3", "name"}, []Attr{}},
87
        CharData("\n    "),
88
        CharData("Some text here."),
89
        CharData("\n  "),
90
        EndElement{Name{"ns3", "name"}},
91
        CharData("\n"),
92
        EndElement{Name{"ns2", "body"}},
93
        Comment(" missing final newline "),
94
}
95
 
96
const testInputAltEncoding = `
97
98
VALUE`
99
 
100
var rawTokensAltEncoding = []Token{
101
        CharData("\n"),
102
        ProcInst{"xml", []byte(`version="1.0" encoding="x-testing-uppercase"`)},
103
        CharData("\n"),
104
        StartElement{Name{"", "tag"}, []Attr{}},
105
        CharData("value"),
106
        EndElement{Name{"", "tag"}},
107
}
108
 
109
var xmlInput = []string{
110
        // unexpected EOF cases
111
        "<",
112
        "
113
        "
114
        "
115
        "
116
        "
117
        "