aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/xml/read_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-07-23 10:28:27 -0400
committerRuss Cox <rsc@golang.org>2015-07-27 16:03:38 +0000
commitc0d6d332f68a38bc13825279d2048a16fffe87f9 (patch)
tree1fe210a19b29e7422f8123c86fd61f98ba6281fc /src/encoding/xml/read_test.go
parentda87cf5dcf342a31c82ff7980bdc076558ff6674 (diff)
downloadgo-c0d6d332f68a38bc13825279d2048a16fffe87f9.tar.xz
encoding/xml: restore Go 1.4 name space behavior
There is clearly work to do here with respect to xml name spaces, but I don't believe the changes in this cycle are clearly correct. The changes in this cycle have visible impact on the generated xml, possibly breaking existing programs, and yet it's not clear that they are the end of the story: there is still significant confusion about how name spaces work or should work (see #9519, #9775, #8167, #7113). I would like to wait to make breaking changes until we completely understand what the behavior should be and can evaluate the benefit of those breaking changes. My main concern here is that we will break programs in Go 1.5 for the sake of name space adjustments and then while trying to fix those other bugs we'll break programs in Go 1.6 too. Let's wait until we know all the changes we want to make before we decide whether or how to break existing programs. This CL reverts: 5ae822b encoding/xml: minor changes bb7e665 encoding/xml: fix xmlns= behavior 9f9d66d encoding/xml: fix default namespace of tags b69ea01 encoding/xml: fix namespaces in a>b tags 3be158d encoding/xml: encoding name spaces correctly and adjusts tests from a9dddb5 encoding/xml: add more EncodeToken tests. to expect Go 1.4 behavior. I have confirmed that the name space parts of the test suite as of this CL passes against the Go 1.4 encoding/xml package, indicating that this CL successfully restores the Go 1.4 behavior. (Other tests do not, but that's because there were some real bug fixes in this cycle that are being kept. Specifically, the tests that don't pass in Go 1.4 are TestMarshal's NestedAndComment case, TestEncodeToken's encoding of newlines, and TestSimpleUseOfEncodeToken returning an error for invalid token types.) I also checked that the Go 1.4 tests pass when run against this copy of the sources. Fixes #11841. Change-Id: I97de06761038b40388ef6e3a55547ff43edee7cb Reviewed-on: https://go-review.googlesource.com/12570 Reviewed-by: Nigel Tao <nigeltao@golang.org>
Diffstat (limited to 'src/encoding/xml/read_test.go')
-rw-r--r--src/encoding/xml/read_test.go32
1 files changed, 1 insertions, 31 deletions
diff --git a/src/encoding/xml/read_test.go b/src/encoding/xml/read_test.go
index 02f1e10c33..7d004dc488 100644
--- a/src/encoding/xml/read_test.go
+++ b/src/encoding/xml/read_test.go
@@ -5,8 +5,6 @@
package xml
import (
- "bytes"
- "fmt"
"io"
"reflect"
"strings"
@@ -486,34 +484,6 @@ func TestUnmarshalNS(t *testing.T) {
}
}
-func TestRoundTrip(t *testing.T) {
- // From issue 7535
- const s = `<ex:element xmlns:ex="http://example.com/schema"></ex:element>`
- in := bytes.NewBufferString(s)
- for i := 0; i < 10; i++ {
- out := &bytes.Buffer{}
- d := NewDecoder(in)
- e := NewEncoder(out)
-
- for {
- t, err := d.Token()
- if err == io.EOF {
- break
- }
- if err != nil {
- fmt.Println("failed:", err)
- return
- }
- e.EncodeToken(t)
- }
- e.Flush()
- in = out
- }
- if got := in.String(); got != s {
- t.Errorf("have: %q\nwant: %q\n", got, s)
- }
-}
-
func TestMarshalNS(t *testing.T) {
dst := Tables{"hello", "world"}
data, err := Marshal(&dst)
@@ -637,7 +607,7 @@ func TestMarshalNSAttr(t *testing.T) {
if err != nil {
t.Fatalf("Marshal: %v", err)
}
- want := `<TableAttrs><TAttr xmlns:json_1="http://golang.org/2/json/" xmlns:json="http://golang.org/json/" xmlns:_xmlfoo="http://golang.org/xmlfoo/" xmlns:_xml="http://golang.org/xml/" xmlns:furniture="http://www.w3schools.com/furniture" xmlns:html4="http://www.w3.org/TR/html4/" html4:table="hello" furniture:table="world" xml:lang="en_US" _xml:other="other1" _xmlfoo:other="other2" json:other="other3" json_1:other="other4"></TAttr></TableAttrs>`
+ want := `<TableAttrs><TAttr xmlns:html4="http://www.w3.org/TR/html4/" html4:table="hello" xmlns:furniture="http://www.w3schools.com/furniture" furniture:table="world" xml:lang="en_US" xmlns:_xml="http://golang.org/xml/" _xml:other="other1" xmlns:_xmlfoo="http://golang.org/xmlfoo/" _xmlfoo:other="other2" xmlns:json="http://golang.org/json/" json:other="other3" xmlns:json_1="http://golang.org/2/json/" json_1:other="other4"></TAttr></TableAttrs>`
str := string(data)
if str != want {
t.Errorf("Marshal:\nhave: %#q\nwant: %#q\n", str, want)