add sub function
This commit is contained in:
@@ -20,3 +20,20 @@ func Test_sum(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_sub(t *testing.T) {
|
||||
tests := []struct {
|
||||
a, b int
|
||||
want int
|
||||
}{
|
||||
{1, 2, -1},
|
||||
{-1, 1, -2},
|
||||
{0, 0, 0},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
if got := sub(test.a, test.b); got != test.want {
|
||||
t.Errorf("sub(%d, %d) = %d, want %d", test.a, test.b, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user