@@ -4,7 +4,7 @@ values in tests. When an assertion fails a helpful error message is printed.
44
55# Example usage
66
7- All the assertions in this package use testing.T.Helper to mark themselves as
7+ All the assertions in this package use [ testing.T.Helper] to mark themselves as
88test helpers. This allows the testing package to print the filename and line
99number of the file function that failed.
1010
@@ -67,19 +67,19 @@ message is omitted from these examples for brevity.
6767
6868# Assert and Check
6969
70- Assert and Check are very similar, they both accept a Comparison, and fail
70+ [ Assert] and [ Check] are very similar, they both accept a [cmp. Comparison] , and fail
7171the test when the comparison fails. The one difference is that Assert uses
72- testing.T.FailNow to fail the test, which will end the test execution immediately.
73- Check uses testing.T.Fail to fail the test, which allows it to return the
72+ [ testing.T.FailNow] to fail the test, which will end the test execution immediately.
73+ Check uses [ testing.T.Fail] to fail the test, which allows it to return the
7474result of the comparison, then proceed with the rest of the test case.
7575
76- Like testing.T.FailNow, Assert must be called from the goroutine running the test,
77- not from other goroutines created during the test. Check is safe to use from any
76+ Like [ testing.T.FailNow], [ Assert] must be called from the goroutine running the test,
77+ not from other goroutines created during the test. [ Check] is safe to use from any
7878goroutine.
7979
8080# Comparisons
8181
82- Package http://pkg.go.dev/ gotest.tools/v3/assert/cmp provides
82+ Package [ gotest.tools/v3/assert/cmp] provides
8383many common comparisons. Additional comparisons can be written to compare
8484values in other ways. See the example Assert (CustomComparison).
8585
@@ -98,11 +98,11 @@ import (
9898 "gotest.tools/v3/internal/assert"
9999)
100100
101- // BoolOrComparison can be a bool, cmp.Comparison, or error. See Assert for
101+ // BoolOrComparison can be a bool, [ cmp.Comparison] , or error. See [ Assert] for
102102// details about how this type is used.
103103type BoolOrComparison interface {}
104104
105- // TestingT is the subset of testing.T used by the assert package.
105+ // TestingT is the subset of [ testing.T] (see also [testing.TB]) used by the assert package.
106106type TestingT interface {
107107 FailNow ()
108108 Fail ()
@@ -133,11 +133,11 @@ type helperT interface {
133133//
134134// Extra details can be added to the failure message using msgAndArgs. msgAndArgs
135135// may be either a single string, or a format string and args that will be
136- // passed to fmt.Sprintf.
136+ // passed to [ fmt.Sprintf] .
137137//
138- // Assert uses t. FailNow to fail the test. Like t.FailNow, Assert must be called
138+ // Assert uses [testing.TB. FailNow] to fail the test. Like t.FailNow, Assert must be called
139139// from the goroutine running the test function, not from other
140- // goroutines created during the test. Use Check from other goroutines.
140+ // goroutines created during the test. Use [ Check] from other goroutines.
141141func Assert (t TestingT , comparison BoolOrComparison , msgAndArgs ... interface {}) {
142142 if ht , ok := t .(helperT ); ok {
143143 ht .Helper ()
@@ -151,7 +151,7 @@ func Assert(t TestingT, comparison BoolOrComparison, msgAndArgs ...interface{})
151151// failed, a failure message is printed, and Check returns false. If the comparison
152152// is successful Check returns true. Check may be called from any goroutine.
153153//
154- // See Assert for details about the comparison arg and failure messages.
154+ // See [ Assert] for details about the comparison arg and failure messages.
155155func Check (t TestingT , comparison BoolOrComparison , msgAndArgs ... interface {}) bool {
156156 if ht , ok := t .(helperT ); ok {
157157 ht .Helper ()
@@ -166,9 +166,9 @@ func Check(t TestingT, comparison BoolOrComparison, msgAndArgs ...interface{}) b
166166// NilError fails the test immediately if err is not nil, and includes err.Error
167167// in the failure message.
168168//
169- // NilError uses t. FailNow to fail the test. Like t.FailNow, NilError must be
169+ // NilError uses [testing.TB. FailNow] to fail the test. Like t.FailNow, NilError must be
170170// called from the goroutine running the test function, not from other
171- // goroutines created during the test. Use Check from other goroutines.
171+ // goroutines created during the test. Use [ Check] from other goroutines.
172172func NilError (t TestingT , err error , msgAndArgs ... interface {}) {
173173 if ht , ok := t .(helperT ); ok {
174174 ht .Helper ()
@@ -193,9 +193,9 @@ func NilError(t TestingT, err error, msgAndArgs ...interface{}) {
193193// the unified diff will be augmented by replacing whitespace characters with
194194// visible characters to identify the whitespace difference.
195195//
196- // Equal uses t. FailNow to fail the test. Like t.FailNow, Equal must be
196+ // Equal uses [testing.T. FailNow] to fail the test. Like t.FailNow, Equal must be
197197// called from the goroutine running the test function, not from other
198- // goroutines created during the test. Use Check with cmp.Equal from other
198+ // goroutines created during the test. Use [ Check] with [ cmp.Equal] from other
199199// goroutines.
200200func Equal (t TestingT , x , y interface {}, msgAndArgs ... interface {}) {
201201 if ht , ok := t .(helperT ); ok {
@@ -206,15 +206,15 @@ func Equal(t TestingT, x, y interface{}, msgAndArgs ...interface{}) {
206206 }
207207}
208208
209- // DeepEqual uses google/go-cmp (https://godoc.org/ github.com/google/go-cmp/cmp)
209+ // DeepEqual uses [ github.com/google/go-cmp/cmp]
210210// to assert two values are equal and fails the test if they are not equal.
211211//
212- // Package http://pkg.go.dev/ gotest.tools/v3/assert/opt provides some additional
212+ // Package [ gotest.tools/v3/assert/opt] provides some additional
213213// commonly used Options.
214214//
215- // DeepEqual uses t. FailNow to fail the test. Like t.FailNow, DeepEqual must be
215+ // DeepEqual uses [testing.T. FailNow] to fail the test. Like t.FailNow, DeepEqual must be
216216// called from the goroutine running the test function, not from other
217- // goroutines created during the test. Use Check with cmp.DeepEqual from other
217+ // goroutines created during the test. Use [ Check] with [ cmp.DeepEqual] from other
218218// goroutines.
219219func DeepEqual (t TestingT , x , y interface {}, opts ... gocmp.Option ) {
220220 if ht , ok := t .(helperT ); ok {
@@ -227,13 +227,13 @@ func DeepEqual(t TestingT, x, y interface{}, opts ...gocmp.Option) {
227227
228228// Error fails the test if err is nil, or if err.Error is not equal to expected.
229229// Both err.Error and expected will be included in the failure message.
230- // Error performs an exact match of the error text. Use ErrorContains if only
231- // part of the error message is relevant. Use ErrorType or ErrorIs to compare
230+ // Error performs an exact match of the error text. Use [ ErrorContains] if only
231+ // part of the error message is relevant. Use [ ErrorType] or [ ErrorIs] to compare
232232// errors by type.
233233//
234- // Error uses t. FailNow to fail the test. Like t.FailNow, Error must be
234+ // Error uses [testing.T. FailNow] to fail the test. Like t.FailNow, Error must be
235235// called from the goroutine running the test function, not from other
236- // goroutines created during the test. Use Check with cmp.Error from other
236+ // goroutines created during the test. Use [ Check] with [ cmp.Error] from other
237237// goroutines.
238238func Error (t TestingT , err error , expected string , msgAndArgs ... interface {}) {
239239 if ht , ok := t .(helperT ); ok {
@@ -248,9 +248,9 @@ func Error(t TestingT, err error, expected string, msgAndArgs ...interface{}) {
248248// contain the expected substring. Both err.Error and the expected substring
249249// will be included in the failure message.
250250//
251- // ErrorContains uses t. FailNow to fail the test. Like t.FailNow, ErrorContains
251+ // ErrorContains uses [testing.T. FailNow] to fail the test. Like t.FailNow, ErrorContains
252252// must be called from the goroutine running the test function, not from other
253- // goroutines created during the test. Use Check with cmp.ErrorContains from other
253+ // goroutines created during the test. Use [ Check] with [ cmp.ErrorContains] from other
254254// goroutines.
255255func ErrorContains (t TestingT , err error , substring string , msgAndArgs ... interface {}) {
256256 if ht , ok := t .(helperT ); ok {
@@ -280,12 +280,12 @@ func ErrorContains(t TestingT, err error, substring string, msgAndArgs ...interf
280280// reflect.Type
281281// The assertion fails if err does not implement the reflect.Type.
282282//
283- // ErrorType uses t. FailNow to fail the test. Like t.FailNow, ErrorType
283+ // ErrorType uses [testing.T. FailNow] to fail the test. Like t.FailNow, ErrorType
284284// must be called from the goroutine running the test function, not from other
285- // goroutines created during the test. Use Check with cmp.ErrorType from other
285+ // goroutines created during the test. Use [ Check] with [ cmp.ErrorType] from other
286286// goroutines.
287287//
288- // Deprecated: Use ErrorIs
288+ // Deprecated: Use [ ErrorIs]
289289func ErrorType (t TestingT , err error , expected interface {}, msgAndArgs ... interface {}) {
290290 if ht , ok := t .(helperT ); ok {
291291 ht .Helper ()
@@ -296,12 +296,12 @@ func ErrorType(t TestingT, err error, expected interface{}, msgAndArgs ...interf
296296}
297297
298298// ErrorIs fails the test if err is nil, or the error does not match expected
299- // when compared using errors.Is. See https://golang.org/pkg/ errors/#Is for
299+ // when compared using errors.Is. See [ errors.Is] for
300300// accepted arguments.
301301//
302- // ErrorIs uses t. FailNow to fail the test. Like t.FailNow, ErrorIs
302+ // ErrorIs uses [testing.T. FailNow] to fail the test. Like t.FailNow, ErrorIs
303303// must be called from the goroutine running the test function, not from other
304- // goroutines created during the test. Use Check with cmp.ErrorIs from other
304+ // goroutines created during the test. Use [ Check] with [ cmp.ErrorIs] from other
305305// goroutines.
306306func ErrorIs (t TestingT , err error , expected error , msgAndArgs ... interface {}) {
307307 if ht , ok := t .(helperT ); ok {
0 commit comments