testutil

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 24 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 CollectLog2 added in v1.3.7

func CollectLog2(t *testing.T, logf func(string, ...any), 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.

func TrimLineSpaces added in v1.3.7

func TrimLineSpaces(str string) string

Useful to compare src code lines.

func TrimLineSpaces2 added in v1.3.7

func TrimLineSpaces2(str string, pre string) string

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
	NoFilepathsFix bool         // don't rewrite filepaths for current dir

	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