1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package main import "testing" import "fmt" 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 }