MCPcopy
hub / github.com/expr-lang/expr / compareTwoValues

Function compareTwoValues

internal/testify/assert/assertion_compare.go:458–479  ·  view source on GitHub ↗
(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

456}
457
458func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
459 if h, ok := t.(tHelper); ok {
460 h.Helper()
461 }
462
463 e1Kind := reflect.ValueOf(e1).Kind()
464 e2Kind := reflect.ValueOf(e2).Kind()
465 if e1Kind != e2Kind {
466 return Fail(t, "Elements should be the same type", msgAndArgs...)
467 }
468
469 compareResult, isComparable := compare(e1, e2, e1Kind)
470 if !isComparable {
471 return Fail(t, fmt.Sprintf("Can not compare type \"%s\"", reflect.TypeOf(e1)), msgAndArgs...)
472 }
473
474 if !containsValue(allowedComparesResults, compareResult) {
475 return Fail(t, fmt.Sprintf(failMessage, e1, e2), msgAndArgs...)
476 }
477
478 return true
479}
480
481func containsValue(values []compareResult, value compareResult) bool {
482 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 5

compareFunction · 0.85
containsValueFunction · 0.85
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…