The alias of testing to ctesting prevented auto-importing of the testing library. This change (arbitrarily) renames the package so that it doesn't collide with the core pkg for "testing".
27 lines
400 B
Go
27 lines
400 B
Go
package tester
|
|
|
|
import (
|
|
"reflect"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// AreSameFunc asserts whether the two funcs are the same func.
|
|
func AreSameFunc(t *testing.T, expect, have any) {
|
|
assert.Equal(
|
|
t,
|
|
runtime.FuncForPC(
|
|
reflect.
|
|
ValueOf(expect).
|
|
Pointer(),
|
|
).Name(),
|
|
runtime.FuncForPC(
|
|
reflect.
|
|
ValueOf(have).
|
|
Pointer(),
|
|
).Name(),
|
|
)
|
|
}
|