main_test.go (558B)
1 package main 2 3 import "testing" 4 5 func TestAdd(t *testing.T) { 6 if got := Add(2, 3); got != 5 { 7 t.Errorf("Add(2, 3) = %d; want 5", got) 8 } 9 } 10 11 func TestAddNegative(t *testing.T) { 12 if got := Add(-1, 1); got != 0 { 13 t.Errorf("Add(-1, 1) = %d; want 0", got) 14 } 15 } 16 17 func TestGreetDefault(t *testing.T) { 18 if got := Greet(""); got != "Hello, world!" { 19 t.Errorf("Greet(\"\") = %q; want \"Hello, world!\"", got) 20 } 21 } 22 23 func TestGreetName(t *testing.T) { 24 if got := Greet("CI"); got != "Hello, CI!" { 25 t.Errorf("Greet(\"CI\") = %q; want \"Hello, CI!\"", got) 26 } 27 }