| 462 | } |
| 463 | |
| 464 | func 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 | |
| 487 | func containsValue(values []compareResult, value compareResult) bool { |
| 488 | for _, v := range values { |