Add basic test in main_test and check it passes with 'go test'
This commit is contained in:
parent
8d0a0e06d2
commit
e5af060488
20
examples/testing/main_test.go
Normal file
20
examples/testing/main_test.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func IntMin(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
} else {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntMinBasic(t *testing.T) {
|
||||
result := IntMin(2, -2)
|
||||
if result != -2 {
|
||||
t.Errorf("IntMin(2, -2) = %d; want -2", result)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user