func TestAddition(t *testing.T) { result := Addition(2, 3) if result != 5 { t.Errorf("Expected 5, got %d", result) } }
func TestDivision(t *testing.T) { _, err := Division(10, 0) if err == nil { t.Errorf("Expected non-nil error, got nil") } }This time we are testing the Division function by passing in a divisor of 0. Since dividing by 0 is not allowed, we expect an error to be returned. We use Errorf to generate an error message if the error is not returned. In both examples, the "testing" package is used as the package library.