internal

package
v0.12.14-0...-c06058b Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RandomStrings = []string{
	"hello world", "²³14234!`§=)$-.€@_&", "This is a sentence.", "This\nstring\nhas\nmultiple\nlines",
	"windows\r\nline\r\nendings", "\rtext",
}

RandomStrings contains a list of random strings to use while testing.

Functions

func CaptureStdout

func CaptureStdout(f func(w io.Writer)) string

CaptureStdout captures everything written to the terminal and returns it as a string.

func GetStringMaxWidth

func GetStringMaxWidth(s string) int

GetStringMaxWidth returns the maximum width of a string with multiple lines.

func MapRangeToRange

func MapRangeToRange(fromMin, fromMax, toMin, toMax, current float32) int

func Percentage

func Percentage(total, current float64) float64

Percentage calculates percentage.

func PercentageRound

func PercentageRound(total, current float64) float64

PercentageRound returns a rounded Percentage.

func RemoveAndCountPrefix

func RemoveAndCountPrefix(input, subString string) (string, int)

func TestDoesNotOutput

func TestDoesNotOutput(t *testing.T, logic func(w io.Writer))

TestDoesNotOutput can be used, to test that something does not output anything to stdout.

func TestDoesOutput

func TestDoesOutput(t *testing.T, logic func(w io.Writer))

TestDoesOutput can be used to test if something is outputted to stdout.

func TestEmpty

func TestEmpty(t *testing.T, logic func(a interface{}) string)

TestEmpty checks that a function does not return a string.

func TestPrintContains

func TestPrintContains(t *testing.T, logic func(w io.Writer, a interface{}))

TestPrintContains can be used to test Print methods.

func TestPrintfContains

func TestPrintfContains(t *testing.T, logic func(w io.Writer, format string, a interface{}))

TestPrintfContains can be used to test Printf methods.

func TestPrintlnContains

func TestPrintlnContains(t *testing.T, logic func(w io.Writer, a interface{}))

TestPrintlnContains can be used to test Println methods.

func TestSprintContains

func TestSprintContains(t *testing.T, logic func(a interface{}) string)

TestSprintContains can be used to test Sprint methods.

func TestSprintContainsWithoutError

func TestSprintContainsWithoutError(t *testing.T, logic func(a interface{}) (string, error))

TestSprintContainsWithoutError can be used to test Sprint methods which return an error.

func TestSprintfContains

func TestSprintfContains(t *testing.T, logic func(format string, a interface{}) string)

TestSprintfContains can be used to test Sprintf methods.

func TestSprintlnContains

func TestSprintlnContains(t *testing.T, logic func(a interface{}) string)

TestSprintlnContains can be used to test Sprintln methods.

func WithBoolean

func WithBoolean(b []bool) bool

WithBoolean helps an option setter (WithXXX(b ...bool) to return true, if no boolean is set, but false if it's explicitly set to false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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