Help us shape the future of Go! Take the 2026 Go Developer Survey

stegol

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

README

STEGoL

License GitHub release Last Commit Go Go Report Card Go Reference

Simple Testing Enhancements for the Go Language

Table of Contents

Introduction

As the name suggests, this is a simple library that provides a bunch of functions/algorithms to assist with testing Go components, as in:

import stegol "github.com/synesissoftware/STEGoL"

Installation & Use

$ go get github.com/synesissoftware/STEGoL
import stegol "github.com/synesissoftware/STEGoL"

Components

Boolean
// Evaluates a boolean value or predicate to obtain a boolean value, calling
// testing.T.Errorf() if the value is not false.
func IsFalse[T ~bool | func() bool](t *testing.T, value T)

// Evaluates a boolean value or predicate to obtain a boolean value, calling
// testing.T.Errorf() if the value is not true.
func IsTrue[T ~bool | Pfunc() bool](t *testing.T, value T)
Integers
// Evaluates two integers, of arbitrary type, for equality comparison,
// calling testing.T.Errorf() if the evaluation fails.
func CheckIntegerEqual[T1 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr, T2 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr](t *testing.T, expected T1, actual T2)

// Evaluates two integers, of arbitrary type, for less-than comparison,
// calling testing.T.Errorf() if the evaluation fails.
func CheckIntegerLess[T1 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr, T2 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr](t *testing.T, expected T1, actual T2)

// Evaluates two integers, of arbitrary type, for less-than-or-equal
// comparison, calling testing.T.Errorf() if the evaluation fails.
func CheckIntegerLessOrEqual[T1 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr, T2 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr](t *testing.T, expected T1, actual T2)

// Evaluates two integers, of arbitrary type, for greater-than comparison,
// calling testing.T.Errorf() if the evaluation fails.
func CheckIntegerGreater[T1 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr, T2 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr](t *testing.T, expected T1, actual T2)

// Evaluates two integers, of arbitrary type, for greater-than-or-equal
// comparison, calling testing.T.Errorf() if the evaluation fails.
func CheckIntegerGreaterOrEqual[T1 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr, T2 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr](t *testing.T, expected T1, actual T2)

// Evaluates two integers, of arbitrary type, for inequality comparison,
// calling testing.T.Errorf() if the evaluation fails.
func CheckIntegerNotEqual[T1 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr, T2 int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr](t *testing.T, expected T1, actual T2)
Strings
// Evaluates two strings for equality, calling testing.T.Errorf() if the
// evaluation fails. The evaluation is done by equality comparison.
func CheckStringEqual(t *testing.T, expected, actual string, options ...any)

// Evaluates two strings for inequality, calling testing.T.Errorf() if the
// evaluation fails. The evaluation is done by equality comparison.
func CheckStringNotEqual(t *testing.T, expected, actual string, options ...any)

// Evaluates two strings for equality, calling testing.T.Errorf() if the
// evaluation fails. The evaluation is done by equality comparison after
// chomping the actual value.
func CheckStringEqualChomped(t *testing.T, expected, actual string, options ...any)

// Evaluates two strings for inequality, calling testing.T.Errorf() if the
// evaluation fails. The evaluation is done by equality comparison after
// chomping the actual value.
func CheckStringNotEqualChomped(t *testing.T, expected, actual string, options ...any)

// Evaluates two strings for equality, calling testing.T.Errorf() if the
// evaluation fails. The evaluation is done by equality comparison after
// whitespace-trimming the actual value.
func CheckStringEqualTrimmed(t *testing.T, expected, actual string, options ...any)

// Evaluates two strings for inequality, calling testing.T.Errorf() if the
// evaluation fails. The evaluation is done by equality comparison after
// whitespace-trimming the actual value.
func CheckStringNotEqualTrimmed(t *testing.T, expected, actual string, options ...any)

// Evaluates two strings for equality, calling testing.T.Errorf() if the
// evaluation fails. The evaluation is done by equality comparison ignoring
// the case of the strings, via the strings.EqualFold() standard library
// function.
func CheckStringEqualIgnoreCase(t *testing.T, expected, actual string, options ...any)

// Evaluates two strings for inequality, calling testing.T.Errorf() if the
// evaluation fails. The evaluation is done by equality comparison ignoring
// the case of the strings, via the strings.EqualFold() standard library
// function.
func CheckStringNotEqualIgnoreCase(t *testing.T, expected, actual string, options ...any)

// Evaluates a string against a regular expression, calling
// testing.T.Error() if it does not.
func CheckStringByStringMatch(t *testing.T, pattern string, actual string, options ...any)

// Evaluates two strings, calling testing.T.Errorf() if the evaluation
// fails. The evaluation is done by the given caller-supplied comparison
// function, whose brief descriptor comparison_type, e.g.
// "regular expression" will be prefixed with the string
// "when compared by ".
func CheckStringCompare(t *testing.T, expected, actual string, fn StringCompareFunc, comparison_type string, options ...any)

// Evaluates a string for equality against an array of string values,
// calling testing.T.Errorf() if every evaluation fails. Each evaluation is
// done by equality comparison.
func CheckStringEqualAny(t *testing.T, expecteds []string, actual string, options ...any)

Examples

Examples are provided in the examples directory, along with a markdown description for each. A detailed list TOC of them is provided in EXAMPLES.md.

Project Information

Where to get help

GitHub Page

Contribution guidelines

Defect reports, feature requests, and pull requests are welcome on https://github.com/synesissoftware/STEGoL.

Dependencies
Development/Testing Dependencies

None

T.B.C.

License

STEGoL is released under the 3-clause BSD license. See LICENSE for details.

Documentation

Index

Constants

View Source
const (
	VersionMajor uint16 = 0
	VersionMinor uint16 = 3
	VersionPatch uint16 = 0
	VersionAB    uint16 = 0xFFFF
	Version      uint64 = (uint64(VersionMajor) << 48) + (uint64(VersionMinor) << 32) + (uint64(VersionPatch) << 16) + (uint64(VersionAB) << 0)
)
View Source
const (
	CheckStringFlag_None = 1 << iota
)

Variables

This section is empty.

Functions

func CheckIntegerEqual added in v0.3.0

func CheckIntegerEqual[T1 Integer, T2 Integer](
	t *testing.T,
	expected T1,
	actual T2,
)

Evaluates two integers, of arbitrary type, for equality comparison, calling testing.T.Errorf() if the evaluation fails.

func CheckIntegerGreater added in v0.3.0

func CheckIntegerGreater[T1 Integer, T2 Integer](
	t *testing.T,
	expected T1,
	actual T2,
)

Evaluates two integers, of arbitrary type, for greater-than comparison, calling testing.T.Errorf() if the evaluation fails.

func CheckIntegerGreaterOrEqual added in v0.3.0

func CheckIntegerGreaterOrEqual[T1 Integer, T2 Integer](
	t *testing.T,
	expected T1,
	actual T2,
)

Evaluates two integers, of arbitrary type, for greater-than-or-equal comparison, calling testing.T.Errorf() if the evaluation fails.

func CheckIntegerLess added in v0.3.0

func CheckIntegerLess[T1 Integer, T2 Integer](
	t *testing.T,
	expected T1,
	actual T2,
)

Evaluates two integers, of arbitrary type, for less-than comparison, calling testing.T.Errorf() if the evaluation fails.

func CheckIntegerLessOrEqual added in v0.3.0

func CheckIntegerLessOrEqual[T1 Integer, T2 Integer](
	t *testing.T,
	expected T1,
	actual T2,
)

Evaluates two integers, of arbitrary type, for less-than-or-equal comparison, calling testing.T.Errorf() if the evaluation fails.

func CheckIntegerNotEqual added in v0.3.0

func CheckIntegerNotEqual[T1 Integer, T2 Integer](
	t *testing.T,
	expected T1,
	actual T2,
)

Evaluates two integers, of arbitrary type, for inequality comparison, calling testing.T.Errorf() if the evaluation fails.

func CheckStringByStringMatch

func CheckStringByStringMatch(
	t *testing.T,
	pattern string,
	actual string,
	options ...any,
)

Evaluates a string against a regular expression, calling testing.T.Error() if it does not.

func CheckStringCompare

func CheckStringCompare(
	t *testing.T,
	expected string,
	actual string,
	fn StringCompareFunc,
	comparison_type string,
	options ...any,
)

Evaluates two strings, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by the given caller-supplied comparison function, whose brief descriptor comparison_type, e.g. "regular expression" will be prefixed with the string "when compared by ".

func CheckStringEqual

func CheckStringEqual(
	t *testing.T,
	expected string,
	actual string,
	options ...any,
)

Evaluates two strings for equality, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by equality comparison.

func CheckStringEqualAny

func CheckStringEqualAny(
	t *testing.T,
	expecteds []string,
	actual string,
	options ...any,
)

Evaluates a string for equality against an array of string values, calling testing.T.Errorf() if every evaluation fails. Each evaluation is done by equality comparison.

func CheckStringEqualChomped added in v0.2.0

func CheckStringEqualChomped(
	t *testing.T,
	expected string,
	actual string,
	options ...any,
)

Evaluates two strings for equality, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by equality comparison after chomping the actual value.

func CheckStringEqualIgnoreCase

func CheckStringEqualIgnoreCase(
	t *testing.T,
	expected string,
	actual string,
	options ...any,
)

Evaluates two strings for equality, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by equality comparison ignoring the case of the strings, via the strings.EqualFold() standard library function.

func CheckStringEqualTrimmed

func CheckStringEqualTrimmed(
	t *testing.T,
	expected string,
	actual string,
	options ...any,
)

Evaluates two strings for equality, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by equality comparison after whitespace-trimming the actual value.

func CheckStringNotEqual added in v0.2.0

func CheckStringNotEqual(
	t *testing.T,
	expected string,
	actual string,
	options ...any,
)

Evaluates two strings for inequality, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by equality comparison.

func CheckStringNotEqualChomped added in v0.2.0

func CheckStringNotEqualChomped(
	t *testing.T,
	expected string,
	actual string,
	options ...any,
)

Evaluates two strings for inequality, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by equality comparison after chomping the actual value.

func CheckStringNotEqualIgnoreCase added in v0.2.0

func CheckStringNotEqualIgnoreCase(
	t *testing.T,
	expected string,
	actual string,
	options ...any,
)

Evaluates two strings for inequality, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by equality comparison ignoring the case of the strings, via the strings.EqualFold() standard library function.

func CheckStringNotEqualTrimmed added in v0.2.0

func CheckStringNotEqualTrimmed(
	t *testing.T,
	expected string,
	actual string,
	options ...any,
)

Evaluates two strings for inequality, calling testing.T.Errorf() if the evaluation fails. The evaluation is done by equality comparison after whitespace-trimming the actual value.

func IsFalse added in v0.3.0

Evaluates a boolean value or predicate to obtain a boolean value, calling testing.T.Errorf() if the value is not false.

func IsTrue added in v0.3.0

Evaluates a boolean value or predicate to obtain a boolean value, calling testing.T.Errorf() if the value is not true.

func VersionString added in v0.2.2

func VersionString() string

Types

type BooleanConvertible added in v0.3.0

type BooleanConvertible interface {
	~bool
}

type CheckStringFlag

type CheckStringFlag int

type Integer added in v0.3.0

type Integer interface {
	SignedInteger | UnsignedInteger
}

type IntegerConvertible added in v0.3.0

type IntegerConvertible interface {
	SignedIntegerConvertible | UnsignedIntegerConvertible
}

type Predicate added in v0.3.0

type Predicate = func() bool

type PredicateWithFailureMessage added in v0.3.0

type PredicateWithFailureMessage = func() (bool, string)

type SignedInteger added in v0.3.0

type SignedInteger interface {
	int | int8 | int16 | int32 | int64
}

type SignedIntegerConvertible added in v0.3.0

type SignedIntegerConvertible interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type StringCompareFunc

type StringCompareFunc func(expected, actual string) bool

type UnsignedInteger added in v0.3.0

type UnsignedInteger interface {
	uint | uint8 | uint16 | uint32 | uint64 | uintptr
}

type UnsignedIntegerConvertible added in v0.3.0

type UnsignedIntegerConvertible interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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