testutil

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: MIT Imports: 3 Imported by: 0

README

Go testing utilities

GoDoc Go Report Card

This package provides the helper functions for testing the code, written in Go.

DoFix

func DoFix() bool

DoFix gets a value indicating whether the xxx_test.go files must not only perform the tests, but also update the files these tests depend on. The value returned by this function is declared via the command line:

go test ... -ldflags="-X 'github.com/umk/go-testutil.fix=fix'"

When the fix variable value equals to "fix", the function returns true, and otherwise false. Use a makefile or a script to run the test command with this parameter for better experience.

After the files have been updated, check with a source control by diff'ing with the current version, that your xxx_test.go have made the proper changes to the files, and run the test again without the fix flag specified.

EqualDiff

func EqualDiff(t *testing.T, expected, actual string, fn string)

EqualDiff checks specified two strings for equality. If they are not equal, its diff is printed to the standard output with the expected value identified by fn, which is supposed to be a file name, where the expected value has been loaded from.

Lfsr28

Lfsr28 is a 28-bit linear-feedback shift register which generates an m-sequence. From Wikipedia:

They are bit sequences generated using maximal linear feedback shift registers and are so called because they are periodic and reproduce every binary sequence (except the zero vector) that can be represented by the shift registers (i.e., for length-m registers they produce a sequence of length 2m − 1).

Use this to produce a pseudo-random sequence of numbers to implement reproducible tests.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoFix

func DoFix() bool

DoFix gets a value indicating whether the xxx_test.go files must not only perform the tests, but also update the files these tests depend on. The value returned by this function is declared via the command line:

go test <...> -ldflags="-X 'github.com/umk/go-testutil.fix=fix'"

When the `fix` variable value equals to "fix", the function returns `true`, and otherwise `false`. Use a makefile or a script to run the test command with this parameter for better experience.

After the files have been updated, check with a source control by diff'ing with the current version, that your xxx_test.go have made the proper changes to the files, and run the test again without the fix flag specified.

func EqualDiff

func EqualDiff(t *testing.T, expected, actual string, fn string)

EqualDiff checks specified two strings for equality. If they are not equal, its diff is printed to the standard output with the expected value identified by `fn`, which is supposed to be a file name, where the expected value has been loaded from.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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