Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmurray-codecov committed Jul 8, 2024
0 parents commit c1d9677
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module go-demo

go 1.22.5
18 changes: 18 additions & 0 deletions main.go
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
}

21 changes: 21 additions & 0 deletions main_test.go
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")
}
}

0 comments on commit c1d9677

Please sign in to comment.