Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / github.com / google / go-cmp@v0.5.1 / cmp / internal / function / func_test.go
1 // Copyright 2019, The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE.md file.
4
5 package function
6
7 import (
8         "bytes"
9         "reflect"
10         "testing"
11 )
12
13 type myType struct{ bytes.Buffer }
14
15 func (myType) valueMethod() {}
16 func (myType) ValueMethod() {}
17
18 func (*myType) pointerMethod() {}
19 func (*myType) PointerMethod() {}
20
21 func 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 }