Skip to content

Commit

Permalink
improve unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blizzy78 committed Mar 29, 2022
1 parent ebdf61b commit d1118fe
Show file tree
Hide file tree
Showing 38 changed files with 722 additions and 537 deletions.
14 changes: 0 additions & 14 deletions testdata/src/chan-recv-ok/test.go

This file was deleted.

11 changes: 11 additions & 0 deletions testdata/src/chanrecv/chanrecv.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package chanrecv

func ChanRecvOK() {
_, ok := <-make(chan int)
// fill
// fill
// fill
// fill
// fill
_ = ok
}
51 changes: 51 additions & 0 deletions testdata/src/conventional/conventional.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package conventional

import (
"context"
"testing"
)

func Variable() {
var (
ctx context.Context
b *testing.B
f *testing.F
m *testing.M
pb *testing.PB
t *testing.T
tb testing.TB
)
// fill
// fill
// fill
// fill
// fill
_ = ctx
_ = b
_ = f
_ = m
_ = pb
_ = t
_ = tb
}

func Param(ctx context.Context,
b *testing.B,
f *testing.F,
m *testing.M,
pb *testing.PB,
t *testing.T,
tb testing.TB) {
// fill
// fill
// fill
// fill
// fill
_ = ctx
_ = b
_ = f
_ = m
_ = pb
_ = t
_ = tb
}
204 changes: 0 additions & 204 deletions testdata/src/decl/test.go

This file was deleted.

10 changes: 10 additions & 0 deletions testdata/src/distance/distance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package distance

func Variable() {
x := 123
_ = x
}

func Param(x int) {
_ = x
}
7 changes: 7 additions & 0 deletions testdata/src/distancereceiver/receiver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package warningsreceiver

type foo struct{}

func (f *foo) Receiver() {
_ = f
}
6 changes: 6 additions & 0 deletions testdata/src/distancereturn/return.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package distancereturn

func Return() (x int) {
x = 123
return
}
21 changes: 21 additions & 0 deletions testdata/src/falsenegativechanrecv/chanrecv .go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package falsenegativechanrecv

func ChanRecvOK_Name() {
_, o := <-make(chan int) // want `variable name 'o' is too short for the scope of its usage`
// fill
// fill
// fill
// fill
// fill
_ = o
}

func ChanRecvOK_Not2() {
ok := <-make(chan int) // want `variable name 'ok' is too short for the scope of its usage`
// fill
// fill
// fill
// fill
// fill
_ = ok
}
21 changes: 21 additions & 0 deletions testdata/src/falsenegativemapindex/mapindex.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package falsenegativemapindex

func MapIndexOK_Name() {
_, o := map[int]int{}[0] // want `variable name 'o' is too short for the scope of its usage`
// fill
// fill
// fill
// fill
// fill
_ = o
}

func MapIndexOK_Not2() {
ok := map[int]int{}[0] // want `variable name 'ok' is too short for the scope of its usage`
// fill
// fill
// fill
// fill
// fill
_ = ok
}
21 changes: 21 additions & 0 deletions testdata/src/falsenegativetypeassert/typeassert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package falsenegativetypeassert

func TypeAssertOK_Name() {
_, o := interface{}(1).(int) // want `variable name 'o' is too short for the scope of its usage`
// fill
// fill
// fill
// fill
// fill
_ = o
}

func TypeAssertOK_Not2() {
ok := interface{}(1).(int) // want `variable name 'ok' is too short for the scope of its usage`
// fill
// fill
// fill
// fill
// fill
_ = ok
}
Loading

0 comments on commit d1118fe

Please sign in to comment.