-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtinysvg_test.go
48 lines (44 loc) · 1.11 KB
/
tinysvg_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
package tinysvg
import (
"bytes"
"testing"
)
func TestSVG(t *testing.T) {
document, svg := NewTinySVG(256, 256)
svg.Describe("Diagram")
roundedRectangle := svg.AddRoundedRect(30, 10, 5, 5, 20, 20)
roundedRectangle.Fill("red")
document.SaveSVG("/tmp/output.svg")
}
func TestString(t *testing.T) {
document, svg := NewTinySVG(256, 256)
svg.Describe("Diagram")
roundedRectangle := svg.AddRoundedRect(30, 10, 5, 5, 20, 20)
roundedRectangle.Fill("red")
s := document.String()
if len(s) != 258 {
t.Fatalf("1: length is not 258 but %d\n", len(s))
}
s = document.String()
if len(s) != 258 {
t.Fatalf("2: length is not 258 but %d\n", len(s))
}
}
func TestWriteTo(t *testing.T) {
document, svg := NewTinySVG(256, 256)
svg.Describe("Diagram")
roundedRectangle := svg.AddRoundedRect(30, 10, 5, 5, 20, 20)
roundedRectangle.Fill("red")
var buf bytes.Buffer
document.WriteTo(&buf)
s := buf.String()
if len(s) != 258 {
t.Fatalf("1: length is not 258 but %d\n", len(s))
}
var buf2 bytes.Buffer
document.WriteTo(&buf2)
s = buf2.String()
if len(s) != 258 {
t.Fatalf("2: length is not 258 but %d\n", len(s))
}
}