-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathprinter_test.go
69 lines (61 loc) · 1.41 KB
/
printer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"bytes"
"testing"
)
func TestCPrint(t *testing.T) {
r := bytes.NewBufferString("hello")
var w bytes.Buffer
err := CPrint(r, &w, LightColorPalettes)
if err != nil {
t.Errorf("error should be nil, but it's %s", err)
}
s := w.String()
if s != "\033[34mhello\033[39;49;00m" {
t.Errorf("output is wrong: %s", s)
}
}
func TestHtmlPrint(t *testing.T) {
r := bytes.NewBufferString("hello")
var w bytes.Buffer
err := HtmlPrint(r, &w, LightColorPalettes)
if err != nil {
t.Errorf("error should be nil, but it's %s", err)
}
expect := `<style>
.black { color: black; }
.blink { color: blink; }
.blue { color: blue; }
.bold { color: bold; }
.brown { color: brown; }
.darkblue { color: darkblue; }
.darkgray { color: darkgray; }
.darkgreen { color: darkgreen; }
.darkred { color: darkred; }
.darkteal { color: darkteal; }
.darkyellow { color: darkyellow; }
.faint { color: faint; }
.fuchsia { color: fuchsia; }
.fuscia { color: fuscia; }
.green { color: green; }
.lightgray { color: lightgray; }
.overline { color: overline; }
.purple { color: purple; }
.red { color: red; }
.reset { color: reset; }
.standout { color: standout; }
.teal { color: teal; }
.turquoise { color: turquoise; }
.underline { color: underline; }
.white { color: white; }
.yellow { color: yellow; }
</style>
<pre>
<span class="darkblue">hello</span>
</pre>
`
s := w.String()
if s != expect {
t.Errorf("output is wrong: %s", s)
}
}