diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-06-18 23:23:36 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-06-19 20:16:11 +0200 |
| commit | 71d31d73e7dc3b9cdb3c53b4f343b1928a9e858b (patch) | |
| tree | e1cd6d01837ef6ef07504ba3893c6f5e55f8740b /assert/assert.go | |
| parent | b95ec7449ebec844221f80ecbf7976f3af878eee (diff) | |
| download | go-gg-71d31d73e7dc3b9cdb3c53b4f343b1928a9e858b.tar.gz | |
add package testcapture, package assert (minimal implementation)
Diffstat (limited to 'assert/assert.go')
| -rw-r--r-- | assert/assert.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/assert/assert.go b/assert/assert.go new file mode 100644 index 0000000..a13c15e --- /dev/null +++ b/assert/assert.go @@ -0,0 +1,42 @@ +// SPDX-FileCopyrightText: 2026 Stefan Majewsky <majewsky@gmx.net> +// SPDX-License-Identifier: Apache-2.0 + +// Package assert contains assertions for use in unit tests. +// Each assertion in this package returns a bool to indicate whether the check succeeded, and logs a t.Error() when the check does not succeed. +package assert + +import ( + "context" + "io" + "testing" +) + +// TestingTB contains all the public functions of [testing.TB] (as of Go 1.26). +// Functions in this package use this type instead of [testing.TB] because the capture device used by package testcapture cannot implement [testing.TB]: It contains methods that are private to the standard library. +type TestingTB interface { + ArtifactDir() string + Attr(key, value string) + Chdir(dir string) + Cleanup(func()) + Context() context.Context + Error(args ...any) + Errorf(format string, args ...any) + Fail() + Failed() bool + FailNow() + Fatal(args ...any) + Fatalf(format string, args ...any) + Helper() + Log(args ...any) + Logf(format string, args ...any) + Name() string + Output() io.Writer + Setenv(key, value string) + Skip(args ...any) + Skipf(format string, args ...any) + SkipNow() + Skipped() bool + TempDir() string +} + +var _ TestingTB = testing.TB(nil) |
