generated from clevergo/pkg-template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstring_test.go
80 lines (69 loc) · 1.59 KB
/
string_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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2020 CleverGo. All rights reserved.
// Use of this source code is governed by a MIT style license that can be found
// in the LICENSE file.
package drivers
import (
"image/color"
"reflect"
"testing"
)
func TestStringHeight(t *testing.T) {
s := &Str{}
StringHeight(4)(s)
if s.height != 4 {
t.Errorf("expected height %d, got %d", 4, s.height)
}
}
func TestStringWidth(t *testing.T) {
s := &Str{}
StringWidth(4)(s)
if s.width != 4 {
t.Errorf("expected width %d, got %d", 4, s.width)
}
}
func TestStringLength(t *testing.T) {
s := &Str{}
StringLength(4)(s)
if s.length != 4 {
t.Errorf("expected length %d, got %d", 4, s.length)
}
}
func TestStringFonts(t *testing.T) {
s := &Str{}
fonts := []string{"wqy_microhei.ttc"}
StringFonts(fonts)(s)
if !reflect.DeepEqual(fonts, s.fonts) {
t.Errorf("expected fonts %v, got %v", fonts, s.fonts)
}
}
func TestStringSource(t *testing.T) {
s := &Str{}
source := "foobar"
StringSource(source)(s)
if s.source != source {
t.Errorf("expected source %s, got %s", source, s.source)
}
}
func TestStringNoiseCount(t *testing.T) {
s := &Str{}
StringNoiseCount(4)(s)
if s.noiseCount != 4 {
t.Errorf("expected noise count %d, got %d", 4, s.noiseCount)
}
}
func TestStringBGColor(t *testing.T) {
s := &Str{}
color := &color.RGBA{1, 2, 3, 4}
StringBGColor(color)(s)
if !reflect.DeepEqual(color, s.bgColor) {
t.Errorf("expected background color %v, got %v", color, s.bgColor)
}
}
func TestNewString(t *testing.T) {
s := NewString(
StringLength(3),
)
if s.length != 3 {
t.Errorf("expected length %d, got %d", 3, s.length)
}
}