-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c1d9677
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module go-demo | ||
|
||
go 1.22.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
func add(a int, b int) int { | ||
return a + b | ||
} | ||
|
||
func subtract(a int, b int) int { | ||
return a - b | ||
} | ||
|
||
func multiply(a int, b int) int { | ||
return a * b | ||
} | ||
|
||
func divide(a float32, b float32) float32 { | ||
return a / b | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func TestAdd(t *testing.T) { | ||
if add(1, 2) != 3 { | ||
t.Fatalf("add(1, 2) != 3") | ||
} | ||
} | ||
|
||
func TestSubtract(t *testing.T) { | ||
if subtract(2, 1) != 1 { | ||
t.Fatalf("subtract(2, 1) != 1") | ||
} | ||
} | ||
|
||
func TestMultiply(t *testing.T) { | ||
if multiply(2, 3) != 6 { | ||
t.Fatalf("multiply(2, 3) != 6") | ||
} | ||
} |