MCPcopy Create free account
hub / github.com/stretchr/testify / Equal

Function Equal

assert/assertions.go:460–479  ·  view source on GitHub ↗

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

458// referenced values (as opposed to the memory addresses). Function equality
459// cannot be determined and will always fail.
460func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
461 if h, ok := t.(tHelper); ok {
462 h.Helper()
463 }
464 if err := validateEqualArgs(expected, actual); err != nil {
465 return Fail(t, fmt.Sprintf("Invalid operation: %#v == %#v (%s)",
466 expected, actual, err), msgAndArgs...)
467 }
468
469 if !ObjectsAreEqual(expected, actual) {
470 diff := diff(expected, actual)
471 expected, actual = formatUnequalValues(expected, actual)
472 return Fail(t, fmt.Sprintf("Not equal: \n"+
473 "expected: %s\n"+
474 "actual : %s%s", expected, actual, diff), msgAndArgs...)
475 }
476
477 return true
478
479}
480
481// validateEqualArgs checks whether provided arguments can be safely used in the
482// 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