29 lines
561 B
Go
29 lines
561 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestAdd(t *testing.T) {
|
|
tests := []struct {
|
|
a, b, want int
|
|
}{
|
|
{2, 3, 5},
|
|
{0, 0, 0},
|
|
{-1, 1, 0},
|
|
{100, 200, 300},
|
|
}
|
|
for _, tt := range tests {
|
|
got := Add(tt.a, tt.b)
|
|
if got != tt.want {
|
|
t.Errorf("Add(%d, %d) = %d, want %d", tt.a, tt.b, got, tt.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestGreet(t *testing.T) {
|
|
got := Greet("World")
|
|
want := "Hello, World!"
|
|
if got != want {
|
|
t.Errorf("Greet(World) = %q, want %q", got, want)
|
|
}
|
|
}
|