add test_case
This commit is contained in:
14
test_case/some.go
Normal file
14
test_case/some.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Add(a, b int32) int32 {
|
||||||
|
return a + b
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("test: ", Add(1, 2))
|
||||||
|
}
|
||||||
|
|
||||||
15
test_case/some_test.go
Normal file
15
test_case/some_test.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAdd(t *testing.T) {
|
||||||
|
a := int32(11)
|
||||||
|
b := int32(22)
|
||||||
|
expect := int32(33)
|
||||||
|
result := Add(a, b)
|
||||||
|
if expect != result {
|
||||||
|
t.Errorf("Error, expect: %d, actual: %d", expect, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user