Skip to content

Commit

Permalink
TestIncrease should test func increase(int, int) int in main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
郑海成 committed Apr 26, 2022
1 parent d618f27 commit 37dfb08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 5 additions & 5 deletions examples/module1/callbacks/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package main

func main() {
var a *int
*a += 1
// DoOperation(1, increase)
DoOperation(1, increase)
DoOperation(1, decrease)
}

func increase(a, b int) int {
println("increase result is:", a+b)
return a + b
}

func DoOperation(y int, f func(int, int)) {
func DoOperation(y int, f func(int, int) int) {
f(y, 1)
}

func decrease(a, b int) {
func decrease(a, b int) int {
println("decrease result is:", a-b)
return a - b
}
5 changes: 1 addition & 4 deletions examples/module1/callbacks/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import (
"github.com/stretchr/testify/assert"
)

func add(a, b int) int {
return a + b
}
func TestIncrease(t *testing.T) {
t.Log("Start testing")
result := add(1, 2)
result := increase(1, 2)
assert.Equal(t, result, 3)
}

1 comment on commit 37dfb08

@zheng11581
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestIncrease should test func increase(int, int) int in main.go

Please sign in to comment.