go-learn/go-testing.go

28 lines
374 B
Go
Raw Permalink Normal View History

2021-03-10 09:13:54 +00:00
package main
import (
"math"
"os"
"testing"
)
//TestAbs comment needed
func TestAbs(t *testing.T) {
// TestAbs comment
got := math.Abs(-1)
if got != 1 {
2021-03-10 11:08:24 +00:00
t.Errorf("Abs(-1) = %f; want 1", got)
2021-03-10 09:13:54 +00:00
}
}
//TestMain comment needed
func TestMain(m *testing.M) {
// call flag.Parse() here if TestMain uses flags
os.Exit(m.Run())
}
func main() {
TestAbs(&testing.T{})
}