-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathzpl_integration_test.go
More file actions
78 lines (62 loc) · 1.31 KB
/
Copy pathzpl_integration_test.go
File metadata and controls
78 lines (62 loc) · 1.31 KB
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
70
71
72
73
74
75
76
77
78
//go:build integration
package zpl_test
import (
"bytes"
"os"
"testing"
"github.com/kamilturek/go-zpl"
zplutils "github.com/kamilturek/go-zpl/utils"
)
func TestConvert(t *testing.T) {
t.Parallel()
args := []string{"testdata/hello.zpl"}
output := &bytes.Buffer{}
if err := zpl.Convert(
zpl.WithInputFromArgs(args),
zpl.WithOutputFormat(zpl.PNG),
zpl.WithOutput(output),
); err != nil {
t.Fatal(err)
}
want, err := os.Open("testdata/hello.png")
if err != nil {
t.Fatal(err)
}
got := output
if err := zplutils.CompareImages(want, got); err != nil {
t.Fatal(err)
}
}
func TestConvertBytes(t *testing.T) {
t.Parallel()
res, err := zpl.ConvertBytes(
[]byte("^xa^cfa,50^fo100,100^fdHello World^fs^xz"),
zpl.WithOutputFormat(zpl.PNG),
)
if err != nil {
t.Fatal(err)
}
want, err := os.Open("testdata/hello.png")
if err != nil {
t.Fatal(err)
}
got := bytes.NewBuffer(res)
if err := zplutils.CompareImages(want, got); err != nil {
t.Fatal(err)
}
}
func TestToPNG(t *testing.T) {
t.Parallel()
res, err := zpl.ToPNG([]byte("^xa^cfa,50^fo100,100^fdHello World^fs^xz"))
if err != nil {
t.Fatal(err)
}
want, err := os.Open("testdata/hello.png")
if err != nil {
t.Fatal(err)
}
got := bytes.NewBuffer(res)
if err := zplutils.CompareImages(want, got); err != nil {
t.Fatal(err)
}
}