package testing
import (
"fmt"
"testing"
)
func TestCalc(t *testing.T){
inputs := [...]int{1,2,3}
expected := [...]int{1,2,9}
for i:=0 ; i <len(inputs);i++{
ret := calc(inputs[i])
if ret != expected[i]{
t.Errorf("input is %d,the expected is %d actual %d",inputs[i],expected[i],ret)
}
}
}
func TestErrorInCode(t *testing.T){
fmt.Println("start")
t.Error("ERROR")
//t.Fatal("error")
fmt.Println("end")
}
Go基础--25 单元测试
由于博客内容为空,暂无法提供包含关键信息的摘要。

被折叠的 条评论
为什么被折叠?



