Documentation ¶
Overview ¶
Package testutil contains common datastructures and functions for testing.
Index ¶
- func GetCaller(level int) (string, string)
- type ErrorTestingBuffer
- type ErrorTestingConnection
- func (c *ErrorTestingConnection) Close() error
- func (c *ErrorTestingConnection) LocalAddr() net.Addr
- func (c *ErrorTestingConnection) Read(b []byte) (n int, err error)
- func (c *ErrorTestingConnection) RemoteAddr() net.Addr
- func (c *ErrorTestingConnection) SetDeadline(t time.Time) error
- func (c *ErrorTestingConnection) SetReadDeadline(t time.Time) error
- func (c *ErrorTestingConnection) SetWriteDeadline(t time.Time) error
- func (c *ErrorTestingConnection) Write(b []byte) (n int, err error)
- type ErrorTestingFile
- type GobTestObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCaller ¶
GetCaller returns the calling function of the function which called it and the code location which called the calling function. Can optionally go further back depending on the level parameter.
For example testfile.go:
20: foo() { 21: x := GetCaller(0) 22: } 23: 24: bar() { 25: foo() 26: }
In the example x would be set to "bar" and location would be testfile.go 25.
Types ¶
type ErrorTestingBuffer ¶
ErrorTestingBuffer is a testing buffer to test error handling for writing operations.
func (ErrorTestingBuffer) Error ¶
func (etb ErrorTestingBuffer) Error() string
Error returns buffer errors. For simplicity the buffer itself implements the error interface.
type ErrorTestingConnection ¶
type ErrorTestingConnection struct { In bytes.Buffer Out bytes.Buffer InErr int OutErr int OutClose bool // contains filtered or unexported fields }
ErrorTestingConnection testing object for connection errors.
func (*ErrorTestingConnection) Close ¶
func (c *ErrorTestingConnection) Close() error
Close is a method stub to satisfy the net.Conn interface.
func (*ErrorTestingConnection) LocalAddr ¶
func (c *ErrorTestingConnection) LocalAddr() net.Addr
LocalAddr is a method stub to satisfy the net.Conn interface.
func (*ErrorTestingConnection) Read ¶
func (c *ErrorTestingConnection) Read(b []byte) (n int, err error)
Read reads from the test connection in buffer.
func (*ErrorTestingConnection) RemoteAddr ¶
func (c *ErrorTestingConnection) RemoteAddr() net.Addr
RemoteAddr is a method stub to satisfy the net.Conn interface.
func (*ErrorTestingConnection) SetDeadline ¶
func (c *ErrorTestingConnection) SetDeadline(t time.Time) error
SetDeadline is a method stub to satisfy the net.Conn interface.
func (*ErrorTestingConnection) SetReadDeadline ¶
func (c *ErrorTestingConnection) SetReadDeadline(t time.Time) error
SetReadDeadline is a method stub to satisfy the net.Conn interface.
func (*ErrorTestingConnection) SetWriteDeadline ¶
func (c *ErrorTestingConnection) SetWriteDeadline(t time.Time) error
SetWriteDeadline is a method stub to satisfy the net.Conn interface.
type ErrorTestingFile ¶
type ErrorTestingFile struct {
Buf *ErrorTestingBuffer
}
ErrorTestingFile is a testing buffer which can be used as an io.File like object.
func NewTestingFile ¶
func NewTestingFile(size int) *ErrorTestingFile
NewTestingFile creates a new test file.
func (ErrorTestingFile) Close ¶
func (etf ErrorTestingFile) Close() error
Close does nothing (there to satisfy interfaces)
func (ErrorTestingFile) Sync ¶
func (etf ErrorTestingFile) Sync() error
Sync does nothing (there to satisfy interfaces)
type GobTestObject ¶
GobTestObject testing object for gob errors.
func (*GobTestObject) GobDecode ¶
func (t *GobTestObject) GobDecode(b []byte) error
GobDecode decodes the given byte array are returns an error.
func (*GobTestObject) GobEncode ¶
func (t *GobTestObject) GobEncode() ([]byte, error)
GobEncode returns a test encoded byte array or an error.