-
Notifications
You must be signed in to change notification settings - Fork 4
/
util_test.go
152 lines (140 loc) · 2.66 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package ecx
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 TestInt64(t *testing.T) {
//given
var input int64 = 20
//when
output := Int64(input)
//then
assert.Equal(t, input, *output, "Input value is same as value of output's pointer")
}
func TestInt64Value(t *testing.T) {
//given
var inputInt int64 = 30
input := []*int64{
&inputInt,
nil,
}
expected := []int64{
inputInt,
0,
}
//when
output := make([]int64, len(input))
for i := range input {
output[i] = Int64Value(input[i])
}
//then
assert.Equal(t, expected, output, "Output matches expected output")
}
func TestFloat64(t *testing.T) {
//given
var input float64 = 20.55
//when
output := Float64(input)
//then
assert.Equal(t, input, *output, "Input value is same as value of output's pointer")
}
func TestFloat64Value(t *testing.T) {
//given
var inputFloat float64 = 30.69
input := []*float64{
&inputFloat,
nil,
}
expected := []float64{
inputFloat,
0,
}
//when
output := make([]float64, len(input))
for i := range input {
output[i] = Float64Value(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")
}