github.com/karrick/go@v0.0.0-20170817181416-d5b0ec858b37/src/cmd/vet/testdata/testingpkg/tests_test.go (about)

     1  package testdata
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  // Buf is a ...
     8  type Buf []byte
     9  
    10  // Append ...
    11  func (*Buf) Append([]byte) {}
    12  
    13  func (Buf) Reset() {}
    14  
    15  func (Buf) Len() int { return 0 }
    16  
    17  // DefaultBuf is a ...
    18  var DefaultBuf Buf
    19  
    20  func Example() {} // OK because is package-level.
    21  
    22  func Example_goodSuffix() // OK because refers to suffix annotation.
    23  
    24  func Example_BadSuffix() // ERROR "Example_BadSuffix has malformed example suffix: BadSuffix"
    25  
    26  func ExampleBuf() // OK because refers to known top-level type.
    27  
    28  func ExampleBuf_Append() {} // OK because refers to known method.
    29  
    30  func ExampleBuf_Clear() {} // ERROR "ExampleBuf_Clear refers to unknown field or method: Buf.Clear"
    31  
    32  func ExampleBuf_suffix() {} // OK because refers to suffix annotation.
    33  
    34  func ExampleBuf_Append_Bad() {} // ERROR "ExampleBuf_Append_Bad has malformed example suffix: Bad"
    35  
    36  func ExampleBuf_Append_suffix() {} // OK because refers to known method with valid suffix.
    37  
    38  func ExampleDefaultBuf() {} // OK because refers to top-level identifier.
    39  
    40  func ExampleBuf_Reset() bool { return true } // ERROR "ExampleBuf_Reset should return nothing"
    41  
    42  func ExampleBuf_Len(i int) {} // ERROR "ExampleBuf_Len should be niladic"
    43  
    44  // "Puffer" is German for "Buffer".
    45  
    46  func ExamplePuffer() // ERROR "ExamplePuffer refers to unknown identifier: Puffer"
    47  
    48  func ExamplePuffer_Append() // ERROR "ExamplePuffer_Append refers to unknown identifier: Puffer"
    49  
    50  func ExamplePuffer_suffix() // ERROR "ExamplePuffer_suffix refers to unknown identifier: Puffer"
    51  
    52  func nonTest() {} // OK because it doesn't start with "Test".
    53  
    54  func (Buf) TesthasReceiver() {} // OK because it has a receiver.
    55  
    56  func TestOKSuffix(*testing.T) {} // OK because first char after "Test" is Uppercase.
    57  
    58  func TestÜnicodeWorks(*testing.T) {} // OK because the first char after "Test" is Uppercase.
    59  
    60  func TestbadSuffix(*testing.T) {} // ERROR "first letter after 'Test' must not be lowercase"
    61  
    62  func TestemptyImportBadSuffix(*T) {} // ERROR "first letter after 'Test' must not be lowercase"
    63  
    64  func Test(*testing.T) {} // OK "Test" on its own is considered a test.
    65  
    66  func Testify() {} // OK because it takes no parameters.
    67  
    68  func TesttooManyParams(*testing.T, string) {} // OK because it takes too many parameters.
    69  
    70  func TesttooManyNames(a, b *testing.T) {} // OK because it takes too many names.
    71  
    72  func TestnoTParam(string) {} // OK because it doesn't take a *testing.T
    73  
    74  func BenchmarkbadSuffix(*testing.B) {} // ERROR "first letter after 'Benchmark' must not be lowercase"