-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathsvgdraw_whitebox_test.go
46 lines (37 loc) · 1003 Bytes
/
svgdraw_whitebox_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
// Copyright 2018 The oksvg Authors. All rights reserved.
// created: 2018 by S.R.Wiley
package oksvg
import "testing"
func TestReadFloat(t *testing.T) {
c := new(PathCursor)
fStr := "23.4.56"
c.ReadFloat(fStr)
if len(c.points) != 2 || c.points[0] != 23.4 || c.points[1] != 0.56 {
t.Error("read float failed", fStr, c.points)
}
c.points = nil
fStr = "23.4"
c.ReadFloat(fStr)
if len(c.points) != 1 || c.points[0] != 23.4 {
t.Error("read float failed", fStr)
}
c.points = nil
fStr = "23"
c.ReadFloat(fStr)
if len(c.points) != 1 || c.points[0] != 23.0 {
t.Error("read float failed", fStr, c.points)
}
c.points = nil
fStr = ".4"
c.ReadFloat(fStr)
if len(c.points) != 1 || c.points[0] != 0.4 {
t.Error("read float failed", fStr, c.points)
}
c.points = nil
fStr = "23.4.56.67.32"
c.ReadFloat(fStr)
if len(c.points) != 4 || c.points[0] != 23.4 || c.points[1] != 0.56 ||
c.points[2] != 0.67 || c.points[3] != 0.32 {
t.Error("read float failed", fStr, c.points)
}
}