23 lines
299 B
Go
23 lines
299 B
Go
package integers
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestAdder(t *testing.T) {
|
|
sum := Add(2, 2)
|
|
// Output: 9
|
|
expected := 4
|
|
|
|
if sum != expected {
|
|
t.Errorf("expected '%d' but got '%d'", expected, sum)
|
|
}
|
|
}
|
|
|
|
// Runnable example testing
|
|
func ExampleAdd() {
|
|
fmt.Println(Add(2, 4))
|
|
// Output: 6
|
|
}
|