blob: 95d8e59da69bf8e207db7af447a2f792db6f5625 [file] [log] [blame]
Holger Hildebrandtda7758b2020-03-16 11:30:03 +00001package assert
2
3import (
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +05304 "bytes"
Holger Hildebrandtda7758b2020-03-16 11:30:03 +00005 "fmt"
6 "reflect"
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +05307 "time"
Holger Hildebrandtda7758b2020-03-16 11:30:03 +00008)
9
mpagenkoaf801632020-07-03 10:00:42 +000010type CompareType int
11
12const (
13 compareLess CompareType = iota - 1
14 compareEqual
15 compareGreater
16)
17
khenaidoo7d3c5582021-08-11 18:09:44 -040018var (
19 intType = reflect.TypeOf(int(1))
20 int8Type = reflect.TypeOf(int8(1))
21 int16Type = reflect.TypeOf(int16(1))
22 int32Type = reflect.TypeOf(int32(1))
23 int64Type = reflect.TypeOf(int64(1))
24
25 uintType = reflect.TypeOf(uint(1))
26 uint8Type = reflect.TypeOf(uint8(1))
27 uint16Type = reflect.TypeOf(uint16(1))
28 uint32Type = reflect.TypeOf(uint32(1))
29 uint64Type = reflect.TypeOf(uint64(1))
30
31 float32Type = reflect.TypeOf(float32(1))
32 float64Type = reflect.TypeOf(float64(1))
33
34 stringType = reflect.TypeOf("")
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +053035
36 timeType = reflect.TypeOf(time.Time{})
37 bytesType = reflect.TypeOf([]byte{})
khenaidoo7d3c5582021-08-11 18:09:44 -040038)
39
mpagenkoaf801632020-07-03 10:00:42 +000040func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
khenaidoo7d3c5582021-08-11 18:09:44 -040041 obj1Value := reflect.ValueOf(obj1)
42 obj2Value := reflect.ValueOf(obj2)
43
44 // throughout this switch we try and avoid calling .Convert() if possible,
45 // as this has a pretty big performance impact
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000046 switch kind {
47 case reflect.Int:
48 {
khenaidoo7d3c5582021-08-11 18:09:44 -040049 intobj1, ok := obj1.(int)
50 if !ok {
51 intobj1 = obj1Value.Convert(intType).Interface().(int)
52 }
53 intobj2, ok := obj2.(int)
54 if !ok {
55 intobj2 = obj2Value.Convert(intType).Interface().(int)
56 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000057 if intobj1 > intobj2 {
mpagenkoaf801632020-07-03 10:00:42 +000058 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000059 }
60 if intobj1 == intobj2 {
mpagenkoaf801632020-07-03 10:00:42 +000061 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000062 }
63 if intobj1 < intobj2 {
mpagenkoaf801632020-07-03 10:00:42 +000064 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000065 }
66 }
67 case reflect.Int8:
68 {
khenaidoo7d3c5582021-08-11 18:09:44 -040069 int8obj1, ok := obj1.(int8)
70 if !ok {
71 int8obj1 = obj1Value.Convert(int8Type).Interface().(int8)
72 }
73 int8obj2, ok := obj2.(int8)
74 if !ok {
75 int8obj2 = obj2Value.Convert(int8Type).Interface().(int8)
76 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000077 if int8obj1 > int8obj2 {
mpagenkoaf801632020-07-03 10:00:42 +000078 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000079 }
80 if int8obj1 == int8obj2 {
mpagenkoaf801632020-07-03 10:00:42 +000081 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000082 }
83 if int8obj1 < int8obj2 {
mpagenkoaf801632020-07-03 10:00:42 +000084 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000085 }
86 }
87 case reflect.Int16:
88 {
khenaidoo7d3c5582021-08-11 18:09:44 -040089 int16obj1, ok := obj1.(int16)
90 if !ok {
91 int16obj1 = obj1Value.Convert(int16Type).Interface().(int16)
92 }
93 int16obj2, ok := obj2.(int16)
94 if !ok {
95 int16obj2 = obj2Value.Convert(int16Type).Interface().(int16)
96 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000097 if int16obj1 > int16obj2 {
mpagenkoaf801632020-07-03 10:00:42 +000098 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +000099 }
100 if int16obj1 == int16obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000101 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000102 }
103 if int16obj1 < int16obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000104 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000105 }
106 }
107 case reflect.Int32:
108 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400109 int32obj1, ok := obj1.(int32)
110 if !ok {
111 int32obj1 = obj1Value.Convert(int32Type).Interface().(int32)
112 }
113 int32obj2, ok := obj2.(int32)
114 if !ok {
115 int32obj2 = obj2Value.Convert(int32Type).Interface().(int32)
116 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000117 if int32obj1 > int32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000118 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000119 }
120 if int32obj1 == int32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000121 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000122 }
123 if int32obj1 < int32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000124 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000125 }
126 }
127 case reflect.Int64:
128 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400129 int64obj1, ok := obj1.(int64)
130 if !ok {
131 int64obj1 = obj1Value.Convert(int64Type).Interface().(int64)
132 }
133 int64obj2, ok := obj2.(int64)
134 if !ok {
135 int64obj2 = obj2Value.Convert(int64Type).Interface().(int64)
136 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000137 if int64obj1 > int64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000138 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000139 }
140 if int64obj1 == int64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000141 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000142 }
143 if int64obj1 < int64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000144 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000145 }
146 }
147 case reflect.Uint:
148 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400149 uintobj1, ok := obj1.(uint)
150 if !ok {
151 uintobj1 = obj1Value.Convert(uintType).Interface().(uint)
152 }
153 uintobj2, ok := obj2.(uint)
154 if !ok {
155 uintobj2 = obj2Value.Convert(uintType).Interface().(uint)
156 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000157 if uintobj1 > uintobj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000158 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000159 }
160 if uintobj1 == uintobj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000161 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000162 }
163 if uintobj1 < uintobj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000164 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000165 }
166 }
167 case reflect.Uint8:
168 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400169 uint8obj1, ok := obj1.(uint8)
170 if !ok {
171 uint8obj1 = obj1Value.Convert(uint8Type).Interface().(uint8)
172 }
173 uint8obj2, ok := obj2.(uint8)
174 if !ok {
175 uint8obj2 = obj2Value.Convert(uint8Type).Interface().(uint8)
176 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000177 if uint8obj1 > uint8obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000178 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000179 }
180 if uint8obj1 == uint8obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000181 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000182 }
183 if uint8obj1 < uint8obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000184 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000185 }
186 }
187 case reflect.Uint16:
188 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400189 uint16obj1, ok := obj1.(uint16)
190 if !ok {
191 uint16obj1 = obj1Value.Convert(uint16Type).Interface().(uint16)
192 }
193 uint16obj2, ok := obj2.(uint16)
194 if !ok {
195 uint16obj2 = obj2Value.Convert(uint16Type).Interface().(uint16)
196 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000197 if uint16obj1 > uint16obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000198 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000199 }
200 if uint16obj1 == uint16obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000201 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000202 }
203 if uint16obj1 < uint16obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000204 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000205 }
206 }
207 case reflect.Uint32:
208 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400209 uint32obj1, ok := obj1.(uint32)
210 if !ok {
211 uint32obj1 = obj1Value.Convert(uint32Type).Interface().(uint32)
212 }
213 uint32obj2, ok := obj2.(uint32)
214 if !ok {
215 uint32obj2 = obj2Value.Convert(uint32Type).Interface().(uint32)
216 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000217 if uint32obj1 > uint32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000218 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000219 }
220 if uint32obj1 == uint32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000221 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000222 }
223 if uint32obj1 < uint32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000224 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000225 }
226 }
227 case reflect.Uint64:
228 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400229 uint64obj1, ok := obj1.(uint64)
230 if !ok {
231 uint64obj1 = obj1Value.Convert(uint64Type).Interface().(uint64)
232 }
233 uint64obj2, ok := obj2.(uint64)
234 if !ok {
235 uint64obj2 = obj2Value.Convert(uint64Type).Interface().(uint64)
236 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000237 if uint64obj1 > uint64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000238 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000239 }
240 if uint64obj1 == uint64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000241 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000242 }
243 if uint64obj1 < uint64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000244 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000245 }
246 }
247 case reflect.Float32:
248 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400249 float32obj1, ok := obj1.(float32)
250 if !ok {
251 float32obj1 = obj1Value.Convert(float32Type).Interface().(float32)
252 }
253 float32obj2, ok := obj2.(float32)
254 if !ok {
255 float32obj2 = obj2Value.Convert(float32Type).Interface().(float32)
256 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000257 if float32obj1 > float32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000258 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000259 }
260 if float32obj1 == float32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000261 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000262 }
263 if float32obj1 < float32obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000264 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000265 }
266 }
267 case reflect.Float64:
268 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400269 float64obj1, ok := obj1.(float64)
270 if !ok {
271 float64obj1 = obj1Value.Convert(float64Type).Interface().(float64)
272 }
273 float64obj2, ok := obj2.(float64)
274 if !ok {
275 float64obj2 = obj2Value.Convert(float64Type).Interface().(float64)
276 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000277 if float64obj1 > float64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000278 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000279 }
280 if float64obj1 == float64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000281 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000282 }
283 if float64obj1 < float64obj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000284 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000285 }
286 }
287 case reflect.String:
288 {
khenaidoo7d3c5582021-08-11 18:09:44 -0400289 stringobj1, ok := obj1.(string)
290 if !ok {
291 stringobj1 = obj1Value.Convert(stringType).Interface().(string)
292 }
293 stringobj2, ok := obj2.(string)
294 if !ok {
295 stringobj2 = obj2Value.Convert(stringType).Interface().(string)
296 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000297 if stringobj1 > stringobj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000298 return compareGreater, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000299 }
300 if stringobj1 == stringobj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000301 return compareEqual, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000302 }
303 if stringobj1 < stringobj2 {
mpagenkoaf801632020-07-03 10:00:42 +0000304 return compareLess, true
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000305 }
306 }
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530307 // Check for known struct types we can check for compare results.
308 case reflect.Struct:
309 {
310 // All structs enter here. We're not interested in most types.
311 if !canConvert(obj1Value, timeType) {
312 break
313 }
314
315 // time.Time can compared!
316 timeObj1, ok := obj1.(time.Time)
317 if !ok {
318 timeObj1 = obj1Value.Convert(timeType).Interface().(time.Time)
319 }
320
321 timeObj2, ok := obj2.(time.Time)
322 if !ok {
323 timeObj2 = obj2Value.Convert(timeType).Interface().(time.Time)
324 }
325
326 return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64)
327 }
328 case reflect.Slice:
329 {
330 // We only care about the []byte type.
331 if !canConvert(obj1Value, bytesType) {
332 break
333 }
334
335 // []byte can be compared!
336 bytesObj1, ok := obj1.([]byte)
337 if !ok {
338 bytesObj1 = obj1Value.Convert(bytesType).Interface().([]byte)
339
340 }
341 bytesObj2, ok := obj2.([]byte)
342 if !ok {
343 bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte)
344 }
345
346 return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true
347 }
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000348 }
349
mpagenkoaf801632020-07-03 10:00:42 +0000350 return compareEqual, false
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000351}
352
353// Greater asserts that the first element is greater than the second
354//
355// assert.Greater(t, 2, 1)
356// assert.Greater(t, float64(2), float64(1))
357// assert.Greater(t, "b", "a")
358func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530359 if h, ok := t.(tHelper); ok {
360 h.Helper()
361 }
362 return compareTwoValues(t, e1, e2, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000363}
364
365// GreaterOrEqual asserts that the first element is greater than or equal to the second
366//
367// assert.GreaterOrEqual(t, 2, 1)
368// assert.GreaterOrEqual(t, 2, 2)
369// assert.GreaterOrEqual(t, "b", "a")
370// assert.GreaterOrEqual(t, "b", "b")
371func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530372 if h, ok := t.(tHelper); ok {
373 h.Helper()
374 }
375 return compareTwoValues(t, e1, e2, []CompareType{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000376}
377
378// Less asserts that the first element is less than the second
379//
380// assert.Less(t, 1, 2)
381// assert.Less(t, float64(1), float64(2))
382// assert.Less(t, "a", "b")
383func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530384 if h, ok := t.(tHelper); ok {
385 h.Helper()
386 }
387 return compareTwoValues(t, e1, e2, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000388}
389
390// LessOrEqual asserts that the first element is less than or equal to the second
391//
392// assert.LessOrEqual(t, 1, 2)
393// assert.LessOrEqual(t, 2, 2)
394// assert.LessOrEqual(t, "a", "b")
395// assert.LessOrEqual(t, "b", "b")
396func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530397 if h, ok := t.(tHelper); ok {
398 h.Helper()
399 }
400 return compareTwoValues(t, e1, e2, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
mpagenkoaf801632020-07-03 10:00:42 +0000401}
402
khenaidoo7d3c5582021-08-11 18:09:44 -0400403// Positive asserts that the specified element is positive
404//
405// assert.Positive(t, 1)
406// assert.Positive(t, 1.23)
407func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530408 if h, ok := t.(tHelper); ok {
409 h.Helper()
410 }
khenaidoo7d3c5582021-08-11 18:09:44 -0400411 zero := reflect.Zero(reflect.TypeOf(e))
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530412 return compareTwoValues(t, e, zero.Interface(), []CompareType{compareGreater}, "\"%v\" is not positive", msgAndArgs...)
khenaidoo7d3c5582021-08-11 18:09:44 -0400413}
414
415// Negative asserts that the specified element is negative
416//
417// assert.Negative(t, -1)
418// assert.Negative(t, -1.23)
419func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530420 if h, ok := t.(tHelper); ok {
421 h.Helper()
422 }
khenaidoo7d3c5582021-08-11 18:09:44 -0400423 zero := reflect.Zero(reflect.TypeOf(e))
Akash Reddy Kankanalac28f0e22025-06-16 11:00:55 +0530424 return compareTwoValues(t, e, zero.Interface(), []CompareType{compareLess}, "\"%v\" is not negative", msgAndArgs...)
khenaidoo7d3c5582021-08-11 18:09:44 -0400425}
426
mpagenkoaf801632020-07-03 10:00:42 +0000427func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000428 if h, ok := t.(tHelper); ok {
429 h.Helper()
430 }
431
432 e1Kind := reflect.ValueOf(e1).Kind()
433 e2Kind := reflect.ValueOf(e2).Kind()
434 if e1Kind != e2Kind {
435 return Fail(t, "Elements should be the same type", msgAndArgs...)
436 }
437
mpagenkoaf801632020-07-03 10:00:42 +0000438 compareResult, isComparable := compare(e1, e2, e1Kind)
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000439 if !isComparable {
440 return Fail(t, fmt.Sprintf("Can not compare type \"%s\"", reflect.TypeOf(e1)), msgAndArgs...)
441 }
442
mpagenkoaf801632020-07-03 10:00:42 +0000443 if !containsValue(allowedComparesResults, compareResult) {
444 return Fail(t, fmt.Sprintf(failMessage, e1, e2), msgAndArgs...)
Holger Hildebrandtda7758b2020-03-16 11:30:03 +0000445 }
446
447 return true
448}
mpagenkoaf801632020-07-03 10:00:42 +0000449
450func containsValue(values []CompareType, value CompareType) bool {
451 for _, v := range values {
452 if v == value {
453 return true
454 }
455 }
456
457 return false
458}