Skip to content

Commit 316ba86

Browse files
committed
adding links to assert pkg
1 parent aafd5de commit 316ba86

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

assert/assert.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ const (
169169
// })
170170
// }
171171
//
172-
// Because PushTester returns PopTester it allows us to merge these two calls to
173-
// one line. See the first t.Run call above. See more information in PopTester.
172+
// Because PushTester returns [PopTester] it allows us to merge these two calls
173+
// to one line. See the first t.Run call above. See more information in
174+
// [PopTester].
174175
//
175176
// PushTester allows you to change the current default asserter by accepting it
176177
// as a second argument.
@@ -200,7 +201,7 @@ func PushTester(t testing.TB, a ...defInd) function {
200201
// memory cleanup and adding similar to err2.Catch error/panic safety for tests.
201202
// By using PopTester you get error logs tuned for unit testing.
202203
//
203-
// You have two ways to call PopTester. With defer right after PushTester:
204+
// You have two ways to call [PopTester]. With defer right after [PushTester]:
204205
//
205206
// for _, tt := range tests {
206207
// t.Run(tt.name, func(t *testing.T) {
@@ -211,7 +212,7 @@ func PushTester(t testing.TB, a ...defInd) function {
211212
// })
212213
// }
213214
//
214-
// If you want to have one liner to combine Push/PopTester:
215+
// If you want, you can combine [PushTester] and PopTester to one-liner:
215216
//
216217
// defer assert.PushTester(t)()
217218
func PopTester() {
@@ -240,7 +241,7 @@ func PopTester() {
240241
// First, print the call stack. Note, that we aren't support full error
241242
// tracing with unit test logging. However, using it has proved the top
242243
// level error stack as more enough. Even so that we could consider using
243-
// it for normal error stack straces if it would be possible.
244+
// it for normal error stack traces if it would be possible.
244245
const stackLvl = 6 // amount of functions before we're here
245246
debug.PrintStackForTest(os.Stderr, stackLvl)
246247

@@ -302,9 +303,8 @@ func Nil[T any](p *T, a ...any) {
302303
// (default Asserter) with the given message.
303304
//
304305
// Note, use this only for real interface types. Go's interface's has two values
305-
// so this won't work e.g. slices! Read more information about interface type.
306-
//
307-
// https://go.dev/doc/faq#nil_error
306+
// so this won't work e.g. slices! Read more information about interface type:
307+
// https://go.dev/doc/faq#nil_error.
308308
func INil(i any, a ...any) {
309309
if i != nil {
310310
defMsg := assertionMsg + ": interface should be nil"
@@ -316,9 +316,8 @@ func INil(i any, a ...any) {
316316
// panics/errors (default Asserter) with the given message.
317317
//
318318
// Note, use this only for real interface types. Go's interface's has two values
319-
// so this won't work e.g. slices! Read more information about interface type.
320-
//
321-
// https://go.dev/doc/faq#nil_error
319+
// so this won't work e.g. slices! Read more information about interface type:
320+
// https://go.dev/doc/faq#nil_error.
322321
func INotNil(i any, a ...any) {
323322
if i == nil {
324323
defMsg := assertionMsg + ": interface shouldn't be nil"
@@ -414,7 +413,7 @@ func NotDeepEqual(val, want any, a ...any) {
414413
// message. You can append the generated got-want message by using optional
415414
// message arguments.
416415
//
417-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
416+
// Note! This is reasonably fast but not as fast as [That] because of lacking
418417
// inlining for the current implementation of Go's type parametric functions.
419418
func Len(obj string, length int, a ...any) {
420419
l := len(obj)
@@ -430,7 +429,7 @@ func Len(obj string, length int, a ...any) {
430429
// message. You can append the generated got-want message by using optional
431430
// message arguments.
432431
//
433-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
432+
// Note! This is reasonably fast but not as fast as [That] because of lacking
434433
// inlining for the current implementation of Go's type parametric functions.
435434
func Longer(s string, length int, a ...any) {
436435
l := len(s)
@@ -446,7 +445,7 @@ func Longer(s string, length int, a ...any) {
446445
// message. You can append the generated got-want message by using optional
447446
// message arguments.
448447
//
449-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
448+
// Note! This is reasonably fast but not as fast as [That] because of lacking
450449
// inlining for the current implementation of Go's type parametric functions.
451450
func Shorter(str string, length int, a ...any) {
452451
l := len(str)
@@ -462,7 +461,7 @@ func Shorter(str string, length int, a ...any) {
462461
// message. You can append the generated got-want message by using optional
463462
// message arguments.
464463
//
465-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
464+
// Note! This is reasonably fast but not as fast as [That] because of lacking
466465
// inlining for the current implementation of Go's type parametric functions.
467466
func SLen[S ~[]T, T any](obj S, length int, a ...any) {
468467
l := len(obj)
@@ -478,7 +477,7 @@ func SLen[S ~[]T, T any](obj S, length int, a ...any) {
478477
// message. You can append the generated got-want message by using optional
479478
// message arguments.
480479
//
481-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
480+
// Note! This is reasonably fast but not as fast as [That] because of lacking
482481
// inlining for the current implementation of Go's type parametric functions.
483482
func SLonger[S ~[]T, T any](obj S, length int, a ...any) {
484483
l := len(obj)
@@ -494,7 +493,7 @@ func SLonger[S ~[]T, T any](obj S, length int, a ...any) {
494493
// message. You can append the generated got-want message by using optional
495494
// message arguments.
496495
//
497-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
496+
// Note! This is reasonably fast but not as fast as [That] because of lacking
498497
// inlining for the current implementation of Go's type parametric functions.
499498
func SShorter[S ~[]T, T any](obj S, length int, a ...any) {
500499
l := len(obj)
@@ -510,7 +509,7 @@ func SShorter[S ~[]T, T any](obj S, length int, a ...any) {
510509
// message. You can append the generated got-want message by using optional
511510
// message arguments.
512511
//
513-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
512+
// Note! This is reasonably fast but not as fast as [That] because of lacking
514513
// inlining for the current implementation of Go's type parametric functions.
515514
func MLen[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
516515
l := len(obj)
@@ -526,7 +525,7 @@ func MLen[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
526525
// message. You can append the generated got-want message by using optional
527526
// message arguments.
528527
//
529-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
528+
// Note! This is reasonably fast but not as fast as [That] because of lacking
530529
// inlining for the current implementation of Go's type parametric functions.
531530
func MLonger[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
532531
l := len(obj)
@@ -542,7 +541,7 @@ func MLonger[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
542541
// message. You can append the generated got-want message by using optional
543542
// message arguments.
544543
//
545-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
544+
// Note! This is reasonably fast but not as fast as [That] because of lacking
546545
// inlining for the current implementation of Go's type parametric functions.
547546
func MShorter[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
548547
l := len(obj)
@@ -558,7 +557,7 @@ func MShorter[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
558557
// message. You can append the generated got-want message by using optional
559558
// message arguments.
560559
//
561-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
560+
// Note! This is reasonably fast but not as fast as [That] because of lacking
562561
// inlining for the current implementation of Go's type parametric functions.
563562
func CLen[C ~chan T, T any](obj C, length int, a ...any) {
564563
l := len(obj)
@@ -574,7 +573,7 @@ func CLen[C ~chan T, T any](obj C, length int, a ...any) {
574573
// message. You can append the generated got-want message by using optional
575574
// message arguments.
576575
//
577-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
576+
// Note! This is reasonably fast but not as fast as [That] because of lacking
578577
// inlining for the current implementation of Go's type parametric functions.
579578
func CLonger[C ~chan T, T any](obj C, length int, a ...any) {
580579
l := len(obj)
@@ -590,7 +589,7 @@ func CLonger[C ~chan T, T any](obj C, length int, a ...any) {
590589
// message. You can append the generated got-want message by using optional
591590
// message arguments.
592591
//
593-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
592+
// Note! This is reasonably fast but not as fast as [That] because of lacking
594593
// inlining for the current implementation of Go's type parametric functions.
595594
func CShorter[C ~chan T, T any](obj C, length int, a ...any) {
596595
l := len(obj)
@@ -638,7 +637,7 @@ func Empty(obj string, a ...any) {
638637
// (according the current Asserter) with the auto-generated message. You can
639638
// append the generated got-want message by using optional message arguments.
640639
//
641-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
640+
// Note! This is reasonably fast but not as fast as [That] because of lacking
642641
// inlining for the current implementation of Go's type parametric functions.
643642
func SNotEmpty[S ~[]T, T any](obj S, a ...any) {
644643
l := len(obj)
@@ -655,7 +654,7 @@ func SNotEmpty[S ~[]T, T any](obj S, a ...any) {
655654
// You can append the generated got-want message by using optional message
656655
// arguments.
657656
//
658-
// Note! This is reasonably fast but not as fast as 'That' because of lacking
657+
// Note! This is reasonably fast but not as fast as [That] because of lacking
659658
// inlining for the current implementation of Go's type parametric functions.
660659
func MNotEmpty[M ~map[T]U, T comparable, U any](obj M, a ...any) {
661660
l := len(obj)
@@ -670,14 +669,15 @@ func MNotEmpty[M ~map[T]U, T comparable, U any](obj M, a ...any) {
670669
// formatting string. Thanks to inlining, the performance penalty is equal to a
671670
// single 'if-statement' that is almost nothing.
672671
//
673-
// Note. We recommend that you prefer try.To. They work exactly the same during
672+
// Note. We recommend that you prefer [try.To]. They work exactly the same during
674673
// the test runs and you can use the same code for both: runtime and tests.
675674
// However, there are cases that you want assert that there is no error in cases
676675
// where fast fail and immediate stop of execution is wanted at runtime. With
677-
// asserts you get the file location as well. (See the asserters).
676+
// asserts ([Production], [Development], [Debug]) you get the file location as
677+
// well.
678678
func NoError(err error, a ...any) {
679679
if err != nil {
680-
defMsg := "NoError:" + assertionMsg + conCatErrStr + err.Error()
680+
defMsg := assertionMsg + conCatErrStr + err.Error()
681681
current().reportAssertionFault(defMsg, a)
682682
}
683683
}

0 commit comments

Comments
 (0)