You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
851 B
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package assert
import (
"strings"
"testing"
)
// Equal a generic function to test equivalence between two values
// of the same type
func Equal[T comparable](t *testing.T, actual, expected T) {
//The t.Helper() function that were using in the code above indicates
// to the Go test runner that our Equal() function is a test helper.
// This means that when t.Errorf() is called from our Equal() function,
// the Go test runner will report the filename and line number of the
// code which called our Equal() function in the output.
t.Helper()
if actual != expected {
t.Errorf("got: %v; want %v", actual, expected)
}
}
func StringContains(t *testing.T, actual, expectedSubstring string) {
t.Helper()
if !strings.Contains(actual, expectedSubstring) {
t.Errorf("got: %q; expected to contain %q", actual, expectedSubstring)
}
}