Documentation
¶
Index ¶
- func AssertEqual[T comparable](t *testing.T, errReason string, want, got T)
- func AssertEqualErr(t *testing.T, errReason string, want, got error)
- func AssertEqualMap[M1, M2 ~map[K]V, K, V comparable](t *testing.T, errReason string, want M1, got M2)
- func AssertEqualSlice[S ~[]E, E comparable](t *testing.T, errReason string, want, got S)
- func AssertNotEqual[T comparable](t *testing.T, errReason string, check, got T)
- func ReplaceRandReader(r io.Reader) (done func())
- func ReplaceStderr() (r *os.File, done func())
- func ReplaceStdin() (w *os.File, done func())
- func ReplaceStdout() (r *os.File, done func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
func AssertEqual[T comparable](t *testing.T, errReason string, want, got T)
AssertEqual checks if the given two values are the same. See also https://go.dev/wiki/TestComments
func AssertEqualErr ¶
AssertEqualErr checks if the given two errors are the same. Errors are checked by following order and considered the same when one of them returned true.
- Compare pointer: want == got
- Compare error: errors.Is(got, want)
- Compare message: want.Error() == got.Error()
See also https://go.dev/wiki/TestComments
func AssertEqualMap ¶
func AssertEqualMap[M1, M2 ~map[K]V, K, V comparable](t *testing.T, errReason string, want M1, got M2)
AssertEqualMap checks if the given two maps are the same using maps.Equal. errReason can be a expression for fmt.Sprintf(errReason, want, got). See also https://go.dev/wiki/TestComments
func AssertEqualSlice ¶
func AssertEqualSlice[S ~[]E, E comparable](t *testing.T, errReason string, want, got S)
AssertEqualSlice checks if the given two slices are the same using slices.Equal. See also https://go.dev/wiki/TestComments
func AssertNotEqual ¶
func AssertNotEqual[T comparable](t *testing.T, errReason string, check, got T)
AssertNotEqual checks if the given two values are not same. See also https://go.dev/wiki/TestComments
func ReplaceRandReader ¶
ReplaceRandReader replaces rand.Reader to the r. Do not run test parallel when using this. Call done function returned from it when tests are completed.
done := ztesting.ReplaceRandReader(YourReader) defer done()
func ReplaceStderr ¶
ReplaceStderr replaces os.Stderr and return reader. Do not run test parallel when using this. Call done function returned from it when tests are completed.
r, done := ztesting.ReplaceStderr() defer done()
func ReplaceStdin ¶
ReplaceStdin replaces os.Stdin and return writer. Do not run test parallel when using this. Call done function returned from it when tests are completed.
w, done := ztesting.ReplaceStdin() defer done()
func ReplaceStdout ¶
ReplaceStdout replaces os.Stdout and return reader. Do not run test parallel when using this. Call done function returned from it when tests are completed.
r, done := ztesting.ReplaceStdout() defer done()
Types ¶
This section is empty.