-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_test.go
66 lines (60 loc) · 1.13 KB
/
map_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
61
62
63
64
65
66
package glyph
import (
"bytes"
"fmt"
"strings"
"testing"
)
func TestMap(t *testing.T) {
{
m := NewMap()
got := len(m.Keys())
want := 0
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
{
m := NewMapWithIncluded()
got := len(m.Keys())
want := len(Included())
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
{
m := NewMapWithIncluded()
g, _ := New()
m.Set("additional-glyph", g)
got := len(m.Keys())
want := len(Included()) + 1
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
{
m := NewMapWithIncluded()
m.Delete("db")
got := len(m.Keys())
want := len(Included()) - 1
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
}
}
func TestMapOption(t *testing.T) {
want := "#FFFFFF"
m := NewMapWithIncluded(Color(want))
g, _ := m.Get("db")
got, _ := g.lineOpts.Get("stroke")
if got != want {
t.Errorf("got %v\nwant %v", got, want)
}
buf := new(bytes.Buffer)
if err := g.Write(buf); err != nil {
t.Fatal(err)
}
if !strings.Contains(buf.String(), fmt.Sprintf("stroke:%s", want)) {
t.Errorf("can not change color\n%v", buf.String())
}
}