-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_test.go
43 lines (30 loc) · 1.05 KB
/
render_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
package footballkit
import (
"bytes"
"image"
"image/png"
"log"
"os"
"testing"
)
func WriteOut(img *image.Image, name string) {
buffer := new(bytes.Buffer)
if err := png.Encode(buffer, *img); err != nil {
log.Println("unable to encode image.")
}
handle, err := os.Create(name)
if err != nil {
return
}
if _, err := handle.Write(buffer.Bytes()); err != nil {
log.Println("unable to write image.")
}
}
func TestAndWriteExamples(t *testing.T) {
WriteOut(RenderImage("body stripes skyblue white shorts navy socks navy"), "example-output/monashunisoccer.png")
WriteOut(RenderImage("body red shorts white socks black"), "example-output/manutd.png")
WriteOut(RenderImage("body claret shorts white socks light blue"), "example-output/astonvilla.png")
WriteOut(RenderImage("hoops green white shorts white socks green"), "example-output/celtic.png")
WriteOut(RenderImage("rightsash white red shorts white socks red"), "example-output/peru.png")
WriteOut(RenderImage("checks red white shorts white socks blue"), "example-output/croatia.png")
}