1 文件名
xxx_test.go
2 函数名
(1) function.go
package fk
func square(op int) int {
return op*op + 1
}
(2) function_test.go
package fk
import "testing"
func Test111(t *testing.T) {
inputs := [...]int{1, 2, 3}
expected := [...]int{1, 4, 9}
for key, val := range inputs {
ret := square(val)
if ret != expected[key] {
t.Errorf("input is %d, expected %d, actual %d", key, expected[key], ret)
}
}
}