-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Hello,
I'm having troubles comparing objects indirectly referencing function pointers.
For the reference, here's a minimal example:
package main
import (
"testing"
assert "github.com/stretchr/testify/assert"
)
type s struct {
f func()
}
func TestAssert(t *testing.T) {
var f = func() {}
var obj = s{f}
assert.Equal(t, obj, obj)
}Testing this code leads to this error:
--- FAIL: TestAssert (0.00s)
main_test.go:17:
Error Trace: main_test.go:17
Error: Not equal:
expected: main.s{f:(func())(0x571380)}
actual : main.s{f:(func())(0x571380)}
Diff:
Test: TestAssert
In my specific case, this function pointer field comes from a private nested structure I don't have the ability to manipulate.
Is there a way to compare structures indirectly embedding a function pointer?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels