-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathutil_test.go
94 lines (86 loc) · 1.59 KB
/
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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package ne
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestString(t *testing.T) {
//given
input := "test"
//when
output := String(input)
//then
assert.Equal(t, input, *output, "Input value is same as value of output's pointer")
}
func TestStringValue(t *testing.T) {
//given
inputString := "test"
input := []*string{
&inputString,
nil,
}
expected := []string{
inputString,
"",
}
//when
output := make([]string, len(input))
for i := range input {
output[i] = StringValue(input[i])
}
//then
assert.Equal(t, expected, output, "Output matches expected output")
}
func TestInt(t *testing.T) {
//given
input := 20
//when
output := Int(input)
//then
assert.Equal(t, input, *output, "Input value is same as value of output's pointer")
}
func TestIntValue(t *testing.T) {
//given
inputInt := 101
input := []*int{
&inputInt,
nil,
}
expected := []int{
inputInt,
0,
}
//when
output := make([]int, len(input))
for i := range input {
output[i] = IntValue(input[i])
}
//then
assert.Equal(t, expected, output, "Output matches expected output")
}
func TestBool(t *testing.T) {
//given
input := false
//when
output := Bool(input)
//then
assert.Equal(t, input, *output, "Input value is same as value of output's pointer")
}
func TestBoolValue(t *testing.T) {
//given
inputBool := false
input := []*bool{
&inputBool,
nil,
}
expected := []bool{
inputBool,
false,
}
//when
output := make([]bool, len(input))
for i := range input {
output[i] = BoolValue(input[i])
}
//then
assert.Equal(t, expected, output, "Output matches expected output")
}