Help us shape the future of Go! Take the 2026 Go Developer Survey

test

package module
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 10 Imported by: 0

README

Test GoDoc

Test is a helper package written in Go. It implements a few functions that are useful for io testing, such as readers and writers that fail after N consecutive reads/writes.

License

Released under the MIT license.

Documentation

Index

Constants

View Source
const (
	Red   = "31"
	Green = "32"
)

Variables

View Source
var ErrPlain = errors.New("error")

ErrPlain is the default error that is returned for functions in this package.

Functions

func Bytes

func Bytes(t *testing.T, got, wanted []byte, msgs ...interface{})

func Error

func Error(t *testing.T, err error, msgs ...interface{})

func Fail

func Fail(t *testing.T, msgs ...interface{})

func Float

func Float(t *testing.T, got, wanted float64, msgs ...interface{})

func Minify

func Minify(t *testing.T, input string, err error, got, wanted string, msgs ...interface{})

func String

func String(t *testing.T, got, wanted string, msgs ...interface{})

func T

func T(t *testing.T, got, wanted interface{}, msgs ...interface{})

func That

func That(t *testing.T, condition bool, msgs ...interface{})

Types

type EmptyReader

type EmptyReader struct {
}

EmptyReader implements an io.Reader that will always return 0, nil.

func NewEmptyReader

func NewEmptyReader() *EmptyReader

NewEmptyReader returns a new EmptyReader.

func (*EmptyReader) Read

func (r *EmptyReader) Read(b []byte) (n int, err error)

Read implements the io.Reader interface.

type ErrorReader

type ErrorReader struct {
	// contains filtered or unexported fields
}

ErrorReader implements an io.Reader that will do N successive reads before it returns ErrPlain.

func NewErrorReader

func NewErrorReader(n int) *ErrorReader

NewErrorReader returns a new ErrorReader.

func (*ErrorReader) Read

func (r *ErrorReader) Read(b []byte) (n int, err error)

Read implements the io.Reader interface.

type ErrorWriter

type ErrorWriter struct {
	// contains filtered or unexported fields
}

ErrorWriter implements an io.Writer that will do N successive writes before it returns ErrPlain.

func NewErrorWriter

func NewErrorWriter(n int) *ErrorWriter

NewErrorWriter returns a new ErrorWriter.

func (*ErrorWriter) Write

func (w *ErrorWriter) Write(b []byte) (n int, err error)

Write implements the io.Writer interface.

type InfiniteReader

type InfiniteReader struct{}

InfiniteReader implements an io.Reader that will always read-in one character.

func NewInfiniteReader

func NewInfiniteReader() *InfiniteReader

NewInfiniteReader returns a new InfiniteReader.

func (*InfiniteReader) Read

func (r *InfiniteReader) Read(b []byte) (n int, err error)

Read implements the io.Reader interface.

type PlainReader

type PlainReader struct {
	// contains filtered or unexported fields
}

PlainReader implements an io.Reader and wraps over an existing io.Reader to hide other functions it implements.

func NewPlainReader

func NewPlainReader(r io.Reader) *PlainReader

NewPlainReader returns a new PlainReader.

func (*PlainReader) Read

func (r *PlainReader) Read(p []byte) (int, error)

Read implements the io.Reader interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL