"std:testing"A minimal testing framework inspired by Go's testing package. Provides test state management, skip functionality, and basic assertion helpers.
View source on Codeberg →type T struct {
name string
failed bool
skipped bool
}
T is the test state type passed to test functions. It tracks the test name, whether it has failed, and whether it has been skipped.
func Name(t *T) string
Returns the name of the running test.
func Failed(t *T) bool
Reports whether the test has been marked as failed.
func Skipped(t *T) bool
Reports whether the test has been skipped.
func Fail(t *T)
Marks the test as failed but continues execution.
func FailNow(t *T)
Marks the test as failed and stops its execution immediately.
func Error(t *T, msg string)
Logs the message and marks the test as failed, but continues execution.
func Errorf(t *T, format string, args ...any)
Logs a formatted message and marks the test as failed, but continues execution.
func Fatal(t *T, msg string)
Logs the message, marks the test as failed, and stops execution immediately.
func Fatalf(t *T, format string, args ...any)
Logs a formatted message, marks the test as failed, and stops execution immediately.
func Log(t *T, msg string)
Records a message in the test log. The message is printed only if the test fails or verbose mode is enabled.
func Logf(t *T, format string, args ...any)
Records a formatted message in the test log. The message is printed only if the test fails or verbose mode is enabled.
func Skip(t *T, reason string)
Logs the reason and marks the test as skipped, stopping its execution.
func Skipf(t *T, format string, args ...any)
Logs a formatted reason and marks the test as skipped, stopping its execution.
func SkipNow(t *T)
Marks the test as skipped and stops its execution immediately without logging a reason.
func AssertEqual(t *T, got, want int)
Asserts that got equals want. If they differ, the test is marked as failed with a diagnostic message showing both values.
func AssertNotEqual(t *T, got, want int)
Asserts that got does not equal want. If they are equal, the test is marked as failed with a diagnostic message.
func AssertTrue(t *T, cond bool, msg string)
Asserts that cond is true. If it is false, the test is marked as failed and the given message is logged.
func AssertFalse(t *T, cond bool, msg string)
Asserts that cond is false. If it is true, the test is marked as failed and the given message is logged.
func AssertStrEqual(t *T, got, want string)
Asserts that the string got equals want. If they differ, the test is marked as failed with a diagnostic message showing both values.
func NewT(name string) *T
Creates and returns a new test state with the given name. The test is initially neither failed nor skipped.
func Report(t *T) int
Prints the test result summary and returns an exit code: 0 if the test passed or was skipped, 1 if it failed.