Documentation
¶
Overview ¶
Package tst provides helper utilities used by tests in this repository.
The helpers include file-content comparisons, stdout capture, and text normalization helpers for stable assertions across platforms.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEqualFiles ¶ added in v0.27.8
AssertEqualFiles fails test if content is NOT equal
func CaptureStdOut ¶
func CaptureStdOut(f func()) string
CaptureStdOut captures stdout and returns it as string.
func EqualLines ¶
EqualLines compares exp and act line by line ignoring line endings and leading/trailing spaces.
func EqualTextFiles ¶
EqualTextFiles fails test if lines in fn0 & fn1 NOT equal. Line endings are ignored
func NormalizeMapString ¶ added in v1.1.0
NormalizeMapString trims insignificant whitespace in Go-style map[string]struct formatting.
It is useful for comparing stringified maps where `fmt.Sprint(map)` includes formatting inconsistencies such as:
- trailing spaces after struct fields (e.g., "{t11 s11 }")
- extra spaces between map entries (e.g., "12:{... }")
This behavior may vary subtly between Go versions (e.g., Go 1.18 vs 1.20+), where `fmt.Sprint` preserves more internal spacing from struct formatting.
normalizeMapString helps produce stable, human-readable string output suitable for comparison in tests without altering the logical content.
func TempFileName ¶
TempFileName returns a temporary file name based on pattern. The file is created and deleted and only the name is delivered. The pattern should contain at least an asterisks. Example: "myFile-*.bin"
Types ¶
This section is empty.