go-by-test/integers/adder_test.go

22 lines
262 B
Go
Raw Normal View History

2024-09-10 11:04:47 +00:00
package integers
2024-09-10 11:09:20 +00:00
import (
"fmt"
"testing"
)
func ExampleAdd() {
sum := Add(1, 5)
fmt.Println(sum)
// Output: 6
}
2024-09-10 11:04:47 +00:00
func TestAdder(t *testing.T) {
sum := Add(2, 2)
expected := 4
if sum != expected {
t.Errorf("got %d, expected %d", sum, expected)
}
}