MCPcopy
hub / github.com/google/go-cmp / TestNameOf

Function TestNameOf

cmp/internal/function/func_test.go:21–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19func (*myType) PointerMethod() {}
20
21func TestNameOf(t *testing.T) {
22 tests := []struct {
23 fnc interface{}
24 want string
25 }{
26 {TestNameOf, "function.TestNameOf"},
27 {func() {}, "function.TestNameOf.func1"},
28 {(myType).valueMethod, "function.myType.valueMethod"},
29 {(myType).ValueMethod, "function.myType.ValueMethod"},
30 {(myType{}).valueMethod, "function.myType.valueMethod"},
31 {(myType{}).ValueMethod, "function.myType.ValueMethod"},
32 {(*myType).valueMethod, "function.myType.valueMethod"},
33 {(*myType).ValueMethod, "function.myType.ValueMethod"},
34 {(&myType{}).valueMethod, "function.myType.valueMethod"},
35 {(&myType{}).ValueMethod, "function.myType.ValueMethod"},
36 {(*myType).pointerMethod, "function.myType.pointerMethod"},
37 {(*myType).PointerMethod, "function.myType.PointerMethod"},
38 {(&myType{}).pointerMethod, "function.myType.pointerMethod"},
39 {(&myType{}).PointerMethod, "function.myType.PointerMethod"},
40 {(*myType).Write, "function.myType.Write"},
41 {(&myType{}).Write, "bytes.Buffer.Write"},
42 }
43 for _, tt := range tests {
44 t.Run("", func(t *testing.T) {
45 got := NameOf(reflect.ValueOf(tt.fnc))
46 if got != tt.want {
47 t.Errorf("NameOf() = %v, want %v", got, tt.want)
48 }
49 })
50 }
51}

Callers

nothing calls this directly

Calls 2

NameOfFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected