(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{})
| 456 | } |
| 457 | |
| 458 | func 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 | |
| 481 | func containsValue(values []compareResult, value compareResult) bool { |
| 482 | for _, v := range values { |
searching dependent graphs…