func TestHelloWorld(t *testing.T) { expected := "Hello, World!" actual := "Hello, World!" if actual != expected { t.Errorf("got %v, want %v", actual, expected) } }
func TestStringContains(t *testing.T) { str := "Hello, World!" subStr := "World" if !strings.Contains(str, subStr) { t.Errorf("got false, want true") } }In this example, we create a test case for the strings.Contains() function. We set the string to "Hello, World!" and the substring to "World". We then use the if statement to check if the contains function returns true. Package library: "strings" package in Go programming language.