Skip to content

Commit

Permalink
[xml] More test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
DHowett committed Mar 21, 2017
1 parent c5eac84 commit 6017651
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions common_data_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,16 @@ var tests = []TestData{
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 35, 127, 240, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17},
},
},
{
Name: "Floating-Point Negative Infinity",
Data: math.Inf(-1),
Expected: map[int][]byte{
OpenStepFormat: []byte(`-Inf`),
GNUStepFormat: []byte(`<*R-Inf>`),
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><real>-inf</real></plist>`),
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 35, 255, 240, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17},
},
},
{
Name: "UTF-8 string",
Data: []string{"Hello, ASCII", "Hello, 世界"},
Expand Down
5 changes: 3 additions & 2 deletions xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ func TestVariousIllegalXMLPlists(t *testing.T) {
"<plist><data>",
"<plist><date>",
"<plist><array>",
"<plist/>",
"<pl",
"bplist00",
}

for _, plist := range plists {
buf := bytes.NewReader([]byte(plist))
d := newXMLPlistParser(buf)
_, err := d.parseDocument()
obj, err := d.parseDocument()
t.Logf("Error: %v", err)
if err == nil {
if obj != nil && err == nil {
t.Error("Expected error, received nothing.")
}
}
Expand Down

0 comments on commit 6017651

Please sign in to comment.