errors

package
v0.0.0-...-37536b8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: BSD-2-Clause Imports: 5 Imported by: 6

Documentation

Overview

Package errors provides all types of test error.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Sprint is used by checker to format actual and expected variables to
	// strings. It has a default implementation and can be replaced with an
	// external function.
	Sprint = func(v interface{}) string {
		return fmt.Sprintf("%v", v)
	}

	// IndentString is the default value for a level of indent.
	IndentString = "    "
)

Functions

func Compare

func Compare(actual, expected interface{}, verb string, name string, skip int) error

Compare returns a new CompareError object.

func Expect

func Expect(text string, skip int) error

Expect returns a new ExpectError object.

func Indent

func Indent(s, indent string) string

Indent splits s to lines and indent each line with argument indent.

Types

type CompareError

type CompareError struct {
	ExpectError
	Actual, Expected interface{}
	Name             string
}

CompareError is the error of comparing two values.

func (*CompareError) Error

func (e *CompareError) Error() string

Error of CompareError formats an error message with the actual, expected value and the verb. When the actual value ends with break, it will add indent accordingly.

type ExpectError

type ExpectError struct {
	Pos  *Pos
	Text string
}

ExpectError is the base type of an expectation error.

func (*ExpectError) Error

func (e *ExpectError) Error() string

Error of ExpectError print the Text field.

type Pos

type Pos struct {
	File string
	Line int
}

Pos represents a position in the source file.

func GetPos

func GetPos(skip int) *Pos

GetPos get the current position of execution.

func (*Pos) BasePath

func (pos *Pos) BasePath() string

BasePath returns the base path of the source file.

func (*Pos) Decorate

func (pos *Pos) Decorate(s, indent string) string

Decorate prefixes the string with the file and line of the call site and inserts the final newline if needed and indentation tabs for formatting.

Jump to

Keyboard shortcuts

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