/
rectangle_test.go
60 lines (53 loc) · 1.16 KB
/
rectangle_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
package ssvgc_test
import (
"testing"
"github.com/llgcode/draw2d/draw2dimg"
"github.com/stephenwithav/ssvgc"
)
type StringMap map[string]string
func TestRectangleDrawing(t *testing.T) {
if testing.Short() {
t.Skip("Skipping lengthier tests during short test run.")
}
var tests = []StringMap{
{
"name": "solidblue",
"fill": "blue",
"width": "400",
"height": "400",
},
{
"name": "redinsetwithblue",
"fill": "blue",
"stroke": "red",
"stroke-width": "30",
"width": "400",
"height": "400",
},
{
"name": "redinsetwithblue2",
"fill": "blue",
"stroke": "red",
"stroke-width": "1",
"width": "400",
"height": "400",
},
{
"name": "solidredstrokedgreen",
"fill": "red",
"width": "100",
"height": "100",
"x": "50",
"y": "50",
"stroke": "green",
"stroke-width": "15",
},
}
for _, tt := range tests {
r := ssvgc.NewRectangle()
for name, value := range tt {
r.SetAttribute(name, value)
}
draw2dimg.SaveToPngFile("output/"+tt["name"]+".png", r.Draw())
}
}