This commit is contained in:
Michael Thomson 2024-05-25 00:42:27 -04:00
parent 1e01d4b8cd
commit fbb4226a84
No known key found for this signature in database
2 changed files with 27 additions and 0 deletions

6
integers/adder.go Normal file
View File

@ -0,0 +1,6 @@
package integers
// Add takes two integers and returns the sum of them
func Add(x, y int) int {
return x + y
}

21
integers/adder_test.go Normal file
View File

@ -0,0 +1,21 @@
package integers
import (
"fmt"
"testing"
)
func TestAdder(t *testing.T) {
sum := Add(2, 2)
expected := 4
if sum != expected {
t.Errorf("expected '%d' but got '%d'", expected, sum)
}
}
func ExampleAdd() {
sum := Add(1, 5)
fmt.Println(sum)
// Output: 6
}