diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-26 23:57:58 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-26 23:57:58 +0000 |
commit | fa5d125b5cfa5c935e46d27a2cbcd71ae37687ac (patch) | |
tree | 19d182df05ead7ff8ba7ee00a7d57555e1383fdf /libgo/go/html/render_test.go | |
parent | e3d46e67996cf20ca3a75fccbb5a0007bfa3f992 (diff) | |
download | ppe42-gcc-fa5d125b5cfa5c935e46d27a2cbcd71ae37687ac.tar.gz ppe42-gcc-fa5d125b5cfa5c935e46d27a2cbcd71ae37687ac.zip |
Update Go library to last weekly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180552 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/html/render_test.go')
-rw-r--r-- | libgo/go/html/render_test.go | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/libgo/go/html/render_test.go b/libgo/go/html/render_test.go new file mode 100644 index 00000000000..d166a3b8736 --- /dev/null +++ b/libgo/go/html/render_test.go @@ -0,0 +1,111 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package html + +import ( + "bytes" + "testing" +) + +func TestRenderer(t *testing.T) { + n := &Node{ + Type: ElementNode, + Data: "html", + Child: []*Node{ + &Node{ + Type: ElementNode, + Data: "head", + }, + &Node{ + Type: ElementNode, + Data: "body", + Child: []*Node{ + &Node{ + Type: TextNode, + Data: "0<1", + }, + &Node{ + Type: ElementNode, + Data: "p", + Attr: []Attribute{ + Attribute{ + Key: "id", + Val: "A", + }, + Attribute{ + Key: "foo", + Val: `abc"def`, + }, + }, + Child: []*Node{ + &Node{ + Type: TextNode, + Data: "2", + }, + &Node{ + Type: ElementNode, + Data: "b", + Attr: []Attribute{ + Attribute{ + Key: "empty", + Val: "", + }, + }, + Child: []*Node{ + &Node{ + Type: TextNode, + Data: "3", + }, + }, + }, + &Node{ + Type: ElementNode, + Data: "i", + Attr: []Attribute{ + Attribute{ + Key: "backslash", + Val: `\`, + }, + }, + Child: []*Node{ + &Node{ + Type: TextNode, + Data: "&4", + }, + }, + }, + }, + }, + &Node{ + Type: TextNode, + Data: "5", + }, + &Node{ + Type: ElementNode, + Data: "blockquote", + }, + &Node{ + Type: ElementNode, + Data: "br", + }, + &Node{ + Type: TextNode, + Data: "6", + }, + }, + }, + }, + } + want := `<html><head></head><body>0<1<p id="A" foo="abc"def">` + + `2<b empty="">3</b><i backslash="\">&4</i></p>` + + `5<blockquote></blockquote><br/>6</body></html>` + b := new(bytes.Buffer) + if err := Render(b, n); err != nil { + t.Fatal(err) + } + if got := b.String(); got != want { + t.Errorf("got vs want:\n%s\n%s\n", got, want) + } +} |