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

Function Equal

assert/assertions.go:495–513  ·  assert/assertions.go::Equal

Equal asserts that two objects are equal. assert.Equal(t, 123, 123) Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses). Function equality cannot be determined and will always fail.

(t TestingT, expected, actual interface{}, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

493// referenced values (as opposed to the memory addresses). Function equality
494// cannot be determined and will always fail.
495func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
496 if h, ok := t.(tHelper); ok {
497 h.Helper()
498 }
499 if err := validateEqualArgs(expected, actual); err != nil {
500 return Fail(t, fmt.Sprintf("Invalid operation: %#v == %#v (%s)",
501 expected, actual, err), msgAndArgs...)
502 }
503
504 if !ObjectsAreEqual(expected, actual) {
505 diff := diff(expected, actual)
506 expected, actual = formatUnequalValues(expected, actual)
507 return Fail(t, fmt.Sprintf("Not equal: \n"+
508 "expected: %s\n"+
509 "actual : %s%s", expected, actual, diff), msgAndArgs...)
510 }
511
512 return true
513}
514
515// validateEqualArgs checks whether provided arguments can be safely used in the
516// Equal/NotEqual functions.

Callers 15

TestImportsFunction · 0.92
TestOneMethod · 0.92
TestRunSuiteFunction · 0.92
TestSuiteGettersFunction · 0.92
TearDownSuiteMethod · 0.92
callOrderAssertFunction · 0.92
AssertNumberOfCallsMethod · 0.92
Test_Mock_TestDataFunction · 0.92
Test_Mock_OnFunction · 0.92
Test_Mock_Chained_OnFunction · 0.92
Test_Mock_On_WithArgsFunction · 0.92
Test_Mock_On_WithFuncArgFunction · 0.92

Calls 6

validateEqualArgsFunction · 0.85
ObjectsAreEqualFunction · 0.85
formatUnequalValuesFunction · 0.85
FailFunction · 0.70
diffFunction · 0.70
HelperMethod · 0.65

Tested by 15

TestImportsFunction · 0.74
TestOneMethod · 0.74
TestRunSuiteFunction · 0.74
TestSuiteGettersFunction · 0.74
TearDownSuiteMethod · 0.74
callOrderAssertFunction · 0.74
Test_Mock_TestDataFunction · 0.74
Test_Mock_OnFunction · 0.74
Test_Mock_Chained_OnFunction · 0.74
Test_Mock_On_WithArgsFunction · 0.74
Test_Mock_On_WithFuncArgFunction · 0.74
TestMock_WithTestFunction · 0.74