Skip to content

Commit 37dfb08

Browse files
author
郑海成
committed
TestIncrease should test func increase(int, int) int in main.go
1 parent d618f27 commit 37dfb08

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

examples/module1/callbacks/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package main
22

33
func main() {
4-
var a *int
5-
*a += 1
6-
// DoOperation(1, increase)
4+
DoOperation(1, increase)
75
DoOperation(1, decrease)
86
}
97

108
func increase(a, b int) int {
9+
println("increase result is:", a+b)
1110
return a + b
1211
}
1312

14-
func DoOperation(y int, f func(int, int)) {
13+
func DoOperation(y int, f func(int, int) int) {
1514
f(y, 1)
1615
}
1716

18-
func decrease(a, b int) {
17+
func decrease(a, b int) int {
1918
println("decrease result is:", a-b)
19+
return a - b
2020
}

examples/module1/callbacks/main_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import (
66
"github.com/stretchr/testify/assert"
77
)
88

9-
func add(a, b int) int {
10-
return a + b
11-
}
129
func TestIncrease(t *testing.T) {
1310
t.Log("Start testing")
14-
result := add(1, 2)
11+
result := increase(1, 2)
1512
assert.Equal(t, result, 3)
1613
}

0 commit comments

Comments
 (0)