+5
Go/integers/adder.go
+5
Go/integers/adder.go
+21
Go/integers/adder_test.go
+21
Go/integers/adder_test.go
···
1
+
package integers
2
+
3
+
import (
4
+
"testing"
5
+
"fmt"
6
+
)
7
+
8
+
func TestAdd(t *testing.T) {
9
+
sum := Add(2, 2)
10
+
expected := 4
11
+
12
+
if sum != expected {
13
+
t.Errorf("expected '%d' but got '%d'", expected, sum)
14
+
}
15
+
}
16
+
17
+
func ExampleAdd() {
18
+
sum := Add(1, 5)
19
+
fmt.Println(sum)
20
+
// Output: 6
21
+
}