-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper_test.go
More file actions
163 lines (154 loc) · 4.01 KB
/
Copy pathwrapper_test.go
File metadata and controls
163 lines (154 loc) · 4.01 KB
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
153
154
155
156
157
158
159
160
161
162
163
// wrapper_test.go
package gonic
import (
"reflect"
"testing"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func TestWrapInt32Slice(t *testing.T) {
tests := []struct {
name string
in []int32
want []*wrapperspb.Int32Value
}{
{"nil", nil, nil},
{"empty", []int32{}, []*wrapperspb.Int32Value{}},
{"values", []int32{1, -2, 3}, []*wrapperspb.Int32Value{
wrapperspb.Int32(1), wrapperspb.Int32(-2), wrapperspb.Int32(3),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := WrapInt32Slice(tt.in)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("WrapInt32Slice(%v) = %v, want %v", tt.in, got, tt.want)
}
})
}
}
func TestWrapInt64Slice(t *testing.T) {
tests := []struct {
name string
in []int64
want []*wrapperspb.Int64Value
}{
{"nil", nil, nil},
{"empty", []int64{}, []*wrapperspb.Int64Value{}},
{"values", []int64{1, -2, 3}, []*wrapperspb.Int64Value{
wrapperspb.Int64(1), wrapperspb.Int64(-2), wrapperspb.Int64(3),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := WrapInt64Slice(tt.in)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("WrapInt64Slice(%v) = %v, want %v", tt.in, got, tt.want)
}
})
}
}
func TestWrapBoolSlice(t *testing.T) {
tests := []struct {
name string
in []bool
want []*wrapperspb.BoolValue
}{
{"nil", nil, nil},
{"empty", []bool{}, []*wrapperspb.BoolValue{}},
{"values", []bool{true, false, true}, []*wrapperspb.BoolValue{
wrapperspb.Bool(true), wrapperspb.Bool(false), wrapperspb.Bool(true),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := WrapBoolSlice(tt.in)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("WrapBoolSlice(%v) = %v, want %v", tt.in, got, tt.want)
}
})
}
}
func TestWrapUint32Slice(t *testing.T) {
tests := []struct {
name string
in []uint32
want []*wrapperspb.UInt32Value
}{
{"nil", nil, nil},
{"empty", []uint32{}, []*wrapperspb.UInt32Value{}},
{"values", []uint32{1, 2, 3}, []*wrapperspb.UInt32Value{
wrapperspb.UInt32(1), wrapperspb.UInt32(2), wrapperspb.UInt32(3),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := WrapUint32Slice(tt.in)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("WrapUint32Slice(%v) = %v, want %v", tt.in, got, tt.want)
}
})
}
}
func TestWrapUint64Slice(t *testing.T) {
tests := []struct {
name string
in []uint64
want []*wrapperspb.UInt64Value
}{
{"nil", nil, nil},
{"empty", []uint64{}, []*wrapperspb.UInt64Value{}},
{"values", []uint64{1, 2, 3}, []*wrapperspb.UInt64Value{
wrapperspb.UInt64(1), wrapperspb.UInt64(2), wrapperspb.UInt64(3),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := WrapUint64Slice(tt.in)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("WrapUint64Slice(%v) = %v, want %v", tt.in, got, tt.want)
}
})
}
}
func TestWrapFloat32Slice(t *testing.T) {
tests := []struct {
name string
in []float32
want []*wrapperspb.FloatValue
}{
{"nil", nil, nil},
{"empty", []float32{}, []*wrapperspb.FloatValue{}},
{"values", []float32{1.1, -2.2, 3.3}, []*wrapperspb.FloatValue{
wrapperspb.Float(1.1), wrapperspb.Float(-2.2), wrapperspb.Float(3.3),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := WrapFloat32Slice(tt.in)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("WrapFloat32Slice(%v) = %v, want %v", tt.in, got, tt.want)
}
})
}
}
func TestWrapFloat64Slice(t *testing.T) {
tests := []struct {
name string
in []float64
want []*wrapperspb.DoubleValue
}{
{"nil", nil, nil},
{"empty", []float64{}, []*wrapperspb.DoubleValue{}},
{"values", []float64{1.1, -2.2, 3.3}, []*wrapperspb.DoubleValue{
wrapperspb.Double(1.1), wrapperspb.Double(-2.2), wrapperspb.Double(3.3),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := WrapFloat64Slice(tt.in)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("WrapFloat64Slice(%v) = %v, want %v", tt.in, got, tt.want)
}
})
}
}