testutil

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearImg

func ClearImg(img draw.Image)

func ClearImg2

func ClearImg2(img draw.Image, c color.Color)

func CollectLog

func CollectLog(t *testing.T, fn func() error) ([]byte, []byte, error)

func CompareImgs

func CompareImgs(img1, img2 image.Image) error

func CompareImgsOrSavePng

func CompareImgsOrSavePng(img1 image.Image, filename2 string) error

func DrawPoint

func DrawPoint(img draw.Image, p image.Point, size int, c color.Color)

func GenerateImg

func GenerateImg(r image.Rectangle, seed int) image.Image

func OpenImage

func OpenImage(filename string) (image.Image, string, error)

func RunArchive

func RunArchive(t *testing.T, ar *Archive, filesExts []string,
	fn func(t2 *testing.T, name string, datas [][]byte) error,
)

Expects n files named in filesExts args

func RunArchive2

func RunArchive2(t *testing.T, ar *Archive,
	fn func(t2 *testing.T, name string, input, output []byte) error,
)

func SPrintImg

func SPrintImg(img image.Image) string

func SPrintImgs

func SPrintImgs(imgs ...image.Image) string

func SourceCursor

func SourceCursor(cursorStr, src string, n int) (string, int, error)

Allows a src string to have multiple cursor strings to simulate cursor position. Used in testing. Useful cursor runes: "●". First n position is zero.

Types

type Archive

type Archive struct {
	Tar      *txtar.Archive
	Filename string // for errors
	Lines    []int  // Tar.Files[] line position in src
}

func ParseTxtar

func ParseTxtar(src []byte, filename string) *Archive

func (*Archive) Error

func (ar *Archive) Error(err error, i int) error

type Script

type Script struct {
	ScriptsDir string
	Args       []string
	Cmds       []*ScriptCmd // user cmds (provided)
	Work       bool         // don't remove work dir at end

	ScriptStart func(*testing.T) error // each script init
	ScriptStop  func(*testing.T) error // each script close
	// contains filtered or unexported fields
}

based on txtar (txt archive)

func NewScript

func NewScript(args []string) *Script

func (*Script) Run

func (scr *Script) Run(t *testing.T)

type ScriptCmd

type ScriptCmd struct {
	Name string
	Fn   func(t *testing.T, args []string) error
}

Jump to

Keyboard shortcuts

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