Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1079)

Side by Side Diff: src/pkg/html/render_test.go

Issue 5451079: code review 5451079: gofmt -s misc src (Closed)
Patch Set: diff -r 90b1026581f1 https://go.googlecode.com/hg/ Created 13 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package html 5 package html
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "testing" 9 "testing"
10 ) 10 )
11 11
12 func TestRenderer(t *testing.T) { 12 func TestRenderer(t *testing.T) {
13 n := &Node{ 13 n := &Node{
14 Type: ElementNode, 14 Type: ElementNode,
15 Data: "html", 15 Data: "html",
16 Child: []*Node{ 16 Child: []*Node{
17 » » » &Node{ 17 » » » {
18 Type: ElementNode, 18 Type: ElementNode,
19 Data: "head", 19 Data: "head",
20 }, 20 },
21 » » » &Node{ 21 » » » {
22 Type: ElementNode, 22 Type: ElementNode,
23 Data: "body", 23 Data: "body",
24 Child: []*Node{ 24 Child: []*Node{
25 » » » » » &Node{ 25 » » » » » {
26 Type: TextNode, 26 Type: TextNode,
27 Data: "0<1", 27 Data: "0<1",
28 }, 28 },
29 » » » » » &Node{ 29 » » » » » {
30 Type: ElementNode, 30 Type: ElementNode,
31 Data: "p", 31 Data: "p",
32 Attr: []Attribute{ 32 Attr: []Attribute{
33 { 33 {
34 Key: "id", 34 Key: "id",
35 Val: "A", 35 Val: "A",
36 }, 36 },
37 { 37 {
38 Key: "foo", 38 Key: "foo",
39 Val: `abc"def`, 39 Val: `abc"def`,
40 }, 40 },
41 }, 41 },
42 Child: []*Node{ 42 Child: []*Node{
43 » » » » » » » &Node{ 43 » » » » » » » {
44 Type: TextNode, 44 Type: TextNode,
45 Data: "2", 45 Data: "2",
46 }, 46 },
47 » » » » » » » &Node{ 47 » » » » » » » {
48 Type: ElementNod e, 48 Type: ElementNod e,
49 Data: "b", 49 Data: "b",
50 Attr: []Attribut e{ 50 Attr: []Attribut e{
51 { 51 {
52 Key: "empty", 52 Key: "empty",
53 Val: "", 53 Val: "",
54 }, 54 },
55 }, 55 },
56 Child: []*Node{ 56 Child: []*Node{
57 » » » » » » » » » &Node{ 57 » » » » » » » » » {
58 Type: TextNode, 58 Type: TextNode,
59 Data: "3", 59 Data: "3",
60 }, 60 },
61 }, 61 },
62 }, 62 },
63 » » » » » » » &Node{ 63 » » » » » » » {
64 Type: ElementNod e, 64 Type: ElementNod e,
65 Data: "i", 65 Data: "i",
66 Attr: []Attribut e{ 66 Attr: []Attribut e{
67 { 67 {
68 Key: "backslash", 68 Key: "backslash",
69 Val: `\`, 69 Val: `\`,
70 }, 70 },
71 }, 71 },
72 Child: []*Node{ 72 Child: []*Node{
73 » » » » » » » » » &Node{ 73 » » » » » » » » » {
74 Type: TextNode, 74 Type: TextNode,
75 Data: "&4", 75 Data: "&4",
76 }, 76 },
77 }, 77 },
78 }, 78 },
79 }, 79 },
80 }, 80 },
81 » » » » » &Node{ 81 » » » » » {
82 Type: TextNode, 82 Type: TextNode,
83 Data: "5", 83 Data: "5",
84 }, 84 },
85 » » » » » &Node{ 85 » » » » » {
86 Type: ElementNode, 86 Type: ElementNode,
87 Data: "blockquote", 87 Data: "blockquote",
88 }, 88 },
89 » » » » » &Node{ 89 » » » » » {
90 Type: ElementNode, 90 Type: ElementNode,
91 Data: "br", 91 Data: "br",
92 }, 92 },
93 » » » » » &Node{ 93 » » » » » {
94 Type: TextNode, 94 Type: TextNode,
95 Data: "6", 95 Data: "6",
96 }, 96 },
97 }, 97 },
98 }, 98 },
99 }, 99 },
100 } 100 }
101 want := `<html><head></head><body>0&lt;1<p id="A" foo="abc&quot;def">` + 101 want := `<html><head></head><body>0&lt;1<p id="A" foo="abc&quot;def">` +
102 `2<b empty="">3</b><i backslash="\">&amp;4</i></p>` + 102 `2<b empty="">3</b><i backslash="\">&amp;4</i></p>` +
103 `5<blockquote></blockquote><br/>6</body></html>` 103 `5<blockquote></blockquote><br/>6</body></html>`
104 b := new(bytes.Buffer) 104 b := new(bytes.Buffer)
105 if err := Render(b, n); err != nil { 105 if err := Render(b, n); err != nil {
106 t.Fatal(err) 106 t.Fatal(err)
107 } 107 }
108 if got := b.String(); got != want { 108 if got := b.String(); got != want {
109 t.Errorf("got vs want:\n%s\n%s\n", got, want) 109 t.Errorf("got vs want:\n%s\n%s\n", got, want)
110 } 110 }
111 } 111 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b