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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [exp/] [html/] [render_test.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2010 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 html
6
 
7
import (
8
        "bytes"
9
        "testing"
10
)
11
 
12
func TestRenderer(t *testing.T) {
13
        n := &Node{
14
                Type: ElementNode,
15
                Data: "html",
16
                Child: []*Node{
17
                        {
18
                                Type: ElementNode,
19
                                Data: "head",
20
                        },
21
                        {
22
                                Type: ElementNode,
23
                                Data: "body",
24
                                Child: []*Node{
25
                                        {
26
                                                Type: TextNode,
27
                                                Data: "0<1",
28
                                        },
29
                                        {
30
                                                Type: ElementNode,
31
                                                Data: "p",
32
                                                Attr: []Attribute{
33
                                                        {
34
                                                                Key: "id",
35
                                                                Val: "A",
36
                                                        },
37
                                                        {
38
                                                                Key: "foo",
39
                                                                Val: `abc"def`,
40
                                                        },
41
                                                },
42
                                                Child: []*Node{
43
                                                        {
44
                                                                Type: TextNode,
45
                                                                Data: "2",
46
                                                        },
47
                                                        {
48
                                                                Type: ElementNode,
49
                                                                Data: "b",
50
                                                                Attr: []Attribute{
51
                                                                        {
52
                                                                                Key: "empty",
53
                                                                                Val: "",
54
                                                                        },
55
                                                                },
56
                                                                Child: []*Node{
57
                                                                        {
58
                                                                                Type: TextNode,
59
                                                                                Data: "3",
60
                                                                        },
61
                                                                },
62
                                                        },
63
                                                        {
64
                                                                Type: ElementNode,
65
                                                                Data: "i",
66
                                                                Attr: []Attribute{
67
                                                                        {
68
                                                                                Key: "backslash",
69
                                                                                Val: `\`,
70
                                                                        },
71
                                                                },
72
                                                                Child: []*Node{
73
                                                                        {
74
                                                                                Type: TextNode,
75
                                                                                Data: "&4",
76
                                                                        },
77
                                                                },
78
                                                        },
79
                                                },
80
                                        },
81
                                        {
82
                                                Type: TextNode,
83
                                                Data: "5",
84
                                        },
85
                                        {
86
                                                Type: ElementNode,
87
                                                Data: "blockquote",
88
                                        },
89
                                        {
90
                                                Type: ElementNode,
91
                                                Data: "br",
92
                                        },
93
                                        {
94
                                                Type: TextNode,
95
                                                Data: "6",
96
                                        },
97
                                },
98
                        },
99
                },
100
        }
101
        want := `0<1

` +

102
                `23&4

` +
103
                `5

6`
104
        b := new(bytes.Buffer)
105
        if err := Render(b, n); err != nil {
106
                t.Fatal(err)
107
        }
108
        if got := b.String(); got != want {
109
                t.Errorf("got vs want:\n%s\n%s\n", got, want)
110
        }
111
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.