-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
51 lines (40 loc) · 949 Bytes
/
util_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
package pixela
import "testing"
func TestString(t *testing.T) {
s := "Hello Pixela!"
result := String(s)
if StringValue(result) != s {
t.Errorf("got: %v\nwant: %v", StringValue(result), s)
}
}
func TestStringValue(t *testing.T) {
a := []*string{String("Hello Pixela!"), nil}
for _, p := range a {
result := StringValue(p)
if p == nil && result != "" {
t.Errorf("got: %v\nwant: %v", result, "\"\"")
}
if p != nil && result != *p {
t.Errorf("got: %v\nwant: %v", result, *p)
}
}
}
func TestBool(t *testing.T) {
b := true
result := Bool(b)
if BoolValue(result) != b {
t.Errorf("got: %v\nwant: %v", BoolValue(result), b)
}
}
func TestBoolValue(t *testing.T) {
a := []*bool{Bool(true), nil}
for _, p := range a {
result := BoolValue(p)
if p == nil && result != false {
t.Errorf("got: %v\nwant: %v", result, false)
}
if p != nil && result != *p {
t.Errorf("got: %v\nwant: %v", result, *p)
}
}
}