import "testing" func TestAddition(t *testing.T) { result := add(2, 3) if result != 5 { t.Fatalf("Expected 5, but got %d", result) } }
import "testing" func TestDivision(t *testing.T) { _, err := divide(5, 0) if err == nil { t.Fatalf("Expected error, but got nil") } }This test checks the output of the `divide` function when passed 5 and 0 as parameters. As expected, the function should return an error. If the function does not return an error, the `T Failed` method is called with an error message indicating that an error was expected, but none was received. Package Library: Testing in standard library