-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfavicon_test.go
52 lines (47 loc) · 1.11 KB
/
favicon_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
package favicon
import (
"bytes"
_ "embed"
"testing"
)
var (
//go:embed test_images/example.svg
exampleFaviconSvg string
//go:embed test_images/example.png
exampleFaviconPng []byte
//go:embed test_images/example.ico
exampleFaviconIco []byte
)
func TestFaviconSvg(t *testing.T) {
c := NewColor()
f := NewSvg("example.com", c)
b, err := f.ProduceSvg()
if err != nil {
t.Fatalf("Failed to generate the SVG: %s", err)
}
if string(b) != exampleFaviconSvg {
t.Fatalf("Generated SVG doesn't match expected result, got: %s", string(b))
}
}
func TestFaviconPng(t *testing.T) {
c := NewColor()
f := NewSvg("example.com", c)
b, err := f.ProducePng()
if err != nil {
t.Fatalf("Failed to rasterize the PNG: %s", err)
}
if bytes.Compare(b, exampleFaviconPng) != 0 {
t.Fatalf("Generated PNG doesn't match expected result")
}
}
func TestFaviconIco(t *testing.T) {
c := NewColor()
f := NewSvg("example.com", c)
b, err := f.ProduceIco()
if err != nil {
t.Fatalf("Failed to rasterize the ICO: %s", err)
}
if bytes.Compare(b, exampleFaviconIco) != 0 {
t.Fatalf("Generated ICO doesn't match expected result")
}
}