Documentation
¶
Index ¶
- func AssertEqual[T any](t *testing.T, msg string, want, got T)
- func AssertEqualErr(t *testing.T, errReason string, want, got error)
- 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 ¶
AssertEqual checks if the given two values are the same. AssertEqual compares want and got using reflect.DeepEqual. See 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()
func ReplaceRandReader ¶
ReplaceRandReader replaces rand.Reader with r. Do not run test parallel when using this. Call done after the test finished to set original rand.Reader.
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 after the test finished to set original Stderr.
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 after the test finished to set original Stdin.
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 after the test finished to set original Stdout.
r, done := ztesting.ReplaceStdout() defer done()
Types ¶
This section is empty.