@@ -7,10 +7,13 @@ import (
7
7
"time"
8
8
)
9
9
10
- type CompareType int
10
+ // Deprecated: CompareType has only ever been for internal use and has accidently been published since v1.6.0. Do not use it.
11
+ type CompareType = compareResult
12
+
13
+ type compareResult int
11
14
12
15
const (
13
- compareLess CompareType = iota - 1
16
+ compareLess compareResult = iota - 1
14
17
compareEqual
15
18
compareGreater
16
19
)
39
42
bytesType = reflect .TypeOf ([]byte {})
40
43
)
41
44
42
- func compare (obj1 , obj2 interface {}, kind reflect.Kind ) (CompareType , bool ) {
45
+ func compare (obj1 , obj2 interface {}, kind reflect.Kind ) (compareResult , bool ) {
43
46
obj1Value := reflect .ValueOf (obj1 )
44
47
obj2Value := reflect .ValueOf (obj2 )
45
48
@@ -345,7 +348,7 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
345
348
bytesObj2 = obj2Value .Convert (bytesType ).Interface ().([]byte )
346
349
}
347
350
348
- return CompareType (bytes .Compare (bytesObj1 , bytesObj2 )), true
351
+ return compareResult (bytes .Compare (bytesObj1 , bytesObj2 )), true
349
352
}
350
353
case reflect .Uintptr :
351
354
{
@@ -381,7 +384,7 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface
381
384
if h , ok := t .(tHelper ); ok {
382
385
h .Helper ()
383
386
}
384
- return compareTwoValues (t , e1 , e2 , []CompareType {compareGreater }, "\" %v\" is not greater than \" %v\" " , msgAndArgs ... )
387
+ return compareTwoValues (t , e1 , e2 , []compareResult {compareGreater }, "\" %v\" is not greater than \" %v\" " , msgAndArgs ... )
385
388
}
386
389
387
390
// GreaterOrEqual asserts that the first element is greater than or equal to the second
@@ -394,7 +397,7 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in
394
397
if h , ok := t .(tHelper ); ok {
395
398
h .Helper ()
396
399
}
397
- return compareTwoValues (t , e1 , e2 , []CompareType {compareGreater , compareEqual }, "\" %v\" is not greater than or equal to \" %v\" " , msgAndArgs ... )
400
+ return compareTwoValues (t , e1 , e2 , []compareResult {compareGreater , compareEqual }, "\" %v\" is not greater than or equal to \" %v\" " , msgAndArgs ... )
398
401
}
399
402
400
403
// Less asserts that the first element is less than the second
@@ -406,7 +409,7 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
406
409
if h , ok := t .(tHelper ); ok {
407
410
h .Helper ()
408
411
}
409
- return compareTwoValues (t , e1 , e2 , []CompareType {compareLess }, "\" %v\" is not less than \" %v\" " , msgAndArgs ... )
412
+ return compareTwoValues (t , e1 , e2 , []compareResult {compareLess }, "\" %v\" is not less than \" %v\" " , msgAndArgs ... )
410
413
}
411
414
412
415
// LessOrEqual asserts that the first element is less than or equal to the second
@@ -419,7 +422,7 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter
419
422
if h , ok := t .(tHelper ); ok {
420
423
h .Helper ()
421
424
}
422
- return compareTwoValues (t , e1 , e2 , []CompareType {compareLess , compareEqual }, "\" %v\" is not less than or equal to \" %v\" " , msgAndArgs ... )
425
+ return compareTwoValues (t , e1 , e2 , []compareResult {compareLess , compareEqual }, "\" %v\" is not less than or equal to \" %v\" " , msgAndArgs ... )
423
426
}
424
427
425
428
// Positive asserts that the specified element is positive
@@ -431,7 +434,7 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
431
434
h .Helper ()
432
435
}
433
436
zero := reflect .Zero (reflect .TypeOf (e ))
434
- return compareTwoValues (t , e , zero .Interface (), []CompareType {compareGreater }, "\" %v\" is not positive" , msgAndArgs ... )
437
+ return compareTwoValues (t , e , zero .Interface (), []compareResult {compareGreater }, "\" %v\" is not positive" , msgAndArgs ... )
435
438
}
436
439
437
440
// Negative asserts that the specified element is negative
@@ -443,10 +446,10 @@ func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
443
446
h .Helper ()
444
447
}
445
448
zero := reflect .Zero (reflect .TypeOf (e ))
446
- return compareTwoValues (t , e , zero .Interface (), []CompareType {compareLess }, "\" %v\" is not negative" , msgAndArgs ... )
449
+ return compareTwoValues (t , e , zero .Interface (), []compareResult {compareLess }, "\" %v\" is not negative" , msgAndArgs ... )
447
450
}
448
451
449
- func compareTwoValues (t TestingT , e1 interface {}, e2 interface {}, allowedComparesResults []CompareType , failMessage string , msgAndArgs ... interface {}) bool {
452
+ func compareTwoValues (t TestingT , e1 interface {}, e2 interface {}, allowedComparesResults []compareResult , failMessage string , msgAndArgs ... interface {}) bool {
450
453
if h , ok := t .(tHelper ); ok {
451
454
h .Helper ()
452
455
}
@@ -469,7 +472,7 @@ func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedCompare
469
472
return true
470
473
}
471
474
472
- func containsValue (values []CompareType , value CompareType ) bool {
475
+ func containsValue (values []compareResult , value compareResult ) bool {
473
476
for _ , v := range values {
474
477
if v == value {
475
478
return true
0 commit comments