MCPcopy
hub / github.com/stretchr/testify / compareTwoValues

Function compareTwoValues

assert/assertion_compare.go:464–485  ·  assert/assertion_compare.go::compareTwoValues
(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

462}
463
464func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
465 if h, ok := t.(tHelper); ok {
466 h.Helper()
467 }
468
469 e1Kind := reflect.ValueOf(e1).Kind()
470 e2Kind := reflect.ValueOf(e2).Kind()
471 if e1Kind != e2Kind {
472 return Fail(t, "Elements should be the same type", msgAndArgs...)
473 }
474
475 compareResult, isComparable := compare(e1, e2, e1Kind)
476 if !isComparable {
477 return Fail(t, fmt.Sprintf(`Can not compare type "%T"`, e1), msgAndArgs...)
478 }
479
480 if !containsValue(allowedComparesResults, compareResult) {
481 return Fail(t, failMessage, msgAndArgs...)
482 }
483
484 return true
485}
486
487func containsValue(values []compareResult, value compareResult) bool {
488 for _, v := range values {

Callers 9

GreaterFunction · 0.85
GreaterOrEqualFunction · 0.85
LessFunction · 0.85
LessOrEqualFunction · 0.85
PositiveFunction · 0.85
NegativeFunction · 0.85

Calls 4

compareFunction · 0.85
containsValueFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65