Skip to content

Commit ddb444c

Browse files
committed
no use variadic expanse in internals
1 parent 097ce05 commit ddb444c

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

assert/assert.go

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func tester() (t testing.TB) {
260260

261261
// NotImplemented always panics with 'not implemented' assertion message.
262262
func NotImplemented(a ...any) {
263-
Default().reportAssertionFault("not implemented", a...)
263+
Default().reportAssertionFault("not implemented", a)
264264
}
265265

266266
// ThatNot asserts that the term is NOT true. If is it panics with the given
@@ -269,7 +269,7 @@ func NotImplemented(a ...any) {
269269
func ThatNot(term bool, a ...any) {
270270
if term {
271271
defMsg := "ThatNot: " + assertionMsg
272-
Default().reportAssertionFault(defMsg, a...)
272+
Default().reportAssertionFault(defMsg, a)
273273
}
274274
}
275275

@@ -279,7 +279,7 @@ func ThatNot(term bool, a ...any) {
279279
func That(term bool, a ...any) {
280280
if !term {
281281
defMsg := "That: " + assertionMsg
282-
Default().reportAssertionFault(defMsg, a...)
282+
Default().reportAssertionFault(defMsg, a)
283283
}
284284
}
285285

@@ -288,7 +288,7 @@ func That(term bool, a ...any) {
288288
func NotNil[P ~*T, T any](p P, a ...any) {
289289
if p == nil {
290290
defMsg := assertionMsg + ": pointer shouldn't be nil"
291-
Default().reportAssertionFault(defMsg, a...)
291+
Default().reportAssertionFault(defMsg, a)
292292
}
293293
}
294294

@@ -297,7 +297,7 @@ func NotNil[P ~*T, T any](p P, a ...any) {
297297
func Nil[T any](p *T, a ...any) {
298298
if p != nil {
299299
defMsg := assertionMsg + ": pointer should be nil"
300-
Default().reportAssertionFault(defMsg, a...)
300+
Default().reportAssertionFault(defMsg, a)
301301
}
302302
}
303303

@@ -311,7 +311,7 @@ func Nil[T any](p *T, a ...any) {
311311
func INil(i any, a ...any) {
312312
if i != nil {
313313
defMsg := assertionMsg + ": interface should be nil"
314-
Default().reportAssertionFault(defMsg, a...)
314+
Default().reportAssertionFault(defMsg, a)
315315
}
316316
}
317317

@@ -325,7 +325,7 @@ func INil(i any, a ...any) {
325325
func INotNil(i any, a ...any) {
326326
if i == nil {
327327
defMsg := assertionMsg + ": interface shouldn't be nil"
328-
Default().reportAssertionFault(defMsg, a...)
328+
Default().reportAssertionFault(defMsg, a)
329329
}
330330
}
331331

@@ -334,7 +334,7 @@ func INotNil(i any, a ...any) {
334334
func SNil[S ~[]T, T any](s S, a ...any) {
335335
if s != nil {
336336
defMsg := assertionMsg + ": slice should be nil"
337-
Default().reportAssertionFault(defMsg, a...)
337+
Default().reportAssertionFault(defMsg, a)
338338
}
339339
}
340340

@@ -343,7 +343,7 @@ func SNil[S ~[]T, T any](s S, a ...any) {
343343
func SNotNil[S ~[]T, T any](s S, a ...any) {
344344
if s == nil {
345345
defMsg := assertionMsg + ": slice shouldn't be nil"
346-
Default().reportAssertionFault(defMsg, a...)
346+
Default().reportAssertionFault(defMsg, a)
347347
}
348348
}
349349

@@ -352,7 +352,7 @@ func SNotNil[S ~[]T, T any](s S, a ...any) {
352352
func CNotNil[C ~chan T, T any](c C, a ...any) {
353353
if c == nil {
354354
defMsg := assertionMsg + ": channel shouldn't be nil"
355-
Default().reportAssertionFault(defMsg, a...)
355+
Default().reportAssertionFault(defMsg, a)
356356
}
357357
}
358358

@@ -361,7 +361,7 @@ func CNotNil[C ~chan T, T any](c C, a ...any) {
361361
func MNotNil[M ~map[T]U, T comparable, U any](m M, a ...any) {
362362
if m == nil {
363363
defMsg := assertionMsg + ": map shouldn't be nil"
364-
Default().reportAssertionFault(defMsg, a...)
364+
Default().reportAssertionFault(defMsg, a)
365365
}
366366
}
367367

@@ -371,7 +371,7 @@ func MNotNil[M ~map[T]U, T comparable, U any](m M, a ...any) {
371371
func NotEqual[T comparable](val, want T, a ...any) {
372372
if want == val {
373373
defMsg := fmt.Sprintf(assertionMsg+": got '%v' want (!= '%v')", val, want)
374-
Default().reportAssertionFault(defMsg, a...)
374+
Default().reportAssertionFault(defMsg, a)
375375
}
376376
}
377377

@@ -381,7 +381,7 @@ func NotEqual[T comparable](val, want T, a ...any) {
381381
func Equal[T comparable](val, want T, a ...any) {
382382
if want != val {
383383
defMsg := fmt.Sprintf(assertionMsg+gotWantFmt, val, want)
384-
Default().reportAssertionFault(defMsg, a...)
384+
Default().reportAssertionFault(defMsg, a)
385385
}
386386
}
387387

@@ -392,7 +392,7 @@ func Equal[T comparable](val, want T, a ...any) {
392392
func DeepEqual(val, want any, a ...any) {
393393
if !reflect.DeepEqual(val, want) {
394394
defMsg := fmt.Sprintf(assertionMsg+gotWantFmt, val, want)
395-
Default().reportAssertionFault(defMsg, a...)
395+
Default().reportAssertionFault(defMsg, a)
396396
}
397397
}
398398

@@ -408,7 +408,7 @@ func DeepEqual(val, want any, a ...any) {
408408
func NotDeepEqual(val, want any, a ...any) {
409409
if reflect.DeepEqual(val, want) {
410410
defMsg := fmt.Sprintf(assertionMsg+": got '%v', want (!= '%v')", val, want)
411-
Default().reportAssertionFault(defMsg, a...)
411+
Default().reportAssertionFault(defMsg, a)
412412
}
413413
}
414414

@@ -424,7 +424,7 @@ func Len(obj string, length int, a ...any) {
424424

425425
if l != length {
426426
defMsg := fmt.Sprintf(assertionMsg+gotWantFmt, l, length)
427-
Default().reportAssertionFault(defMsg, a...)
427+
Default().reportAssertionFault(defMsg, a)
428428
}
429429
}
430430

@@ -440,7 +440,7 @@ func Longer(obj string, length int, a ...any) {
440440

441441
if l > length {
442442
defMsg := fmt.Sprintf(assertionMsg+gotWantLongerFmt, l, length)
443-
Default().reportAssertionFault(defMsg, a...)
443+
Default().reportAssertionFault(defMsg, a)
444444
}
445445
}
446446

@@ -456,7 +456,7 @@ func Shorter(obj string, length int, a ...any) {
456456

457457
if l <= length {
458458
defMsg := fmt.Sprintf(assertionMsg+gotWantShorterFmt, l, length)
459-
Default().reportAssertionFault(defMsg, a...)
459+
Default().reportAssertionFault(defMsg, a)
460460
}
461461
}
462462

@@ -472,7 +472,7 @@ func SLen[S ~[]T, T any](obj S, length int, a ...any) {
472472

473473
if l != length {
474474
defMsg := fmt.Sprintf(assertionMsg+gotWantFmt, l, length)
475-
Default().reportAssertionFault(defMsg, a...)
475+
Default().reportAssertionFault(defMsg, a)
476476
}
477477
}
478478

@@ -488,7 +488,7 @@ func SLonger[S ~[]T, T any](obj S, length int, a ...any) {
488488

489489
if l <= length {
490490
defMsg := fmt.Sprintf(assertionMsg+gotWantLongerFmt, l, length)
491-
Default().reportAssertionFault(defMsg, a...)
491+
Default().reportAssertionFault(defMsg, a)
492492
}
493493
}
494494

@@ -504,7 +504,7 @@ func SShorter[S ~[]T, T any](obj S, length int, a ...any) {
504504

505505
if l >= length {
506506
defMsg := fmt.Sprintf(assertionMsg+gotWantShorterFmt, l, length)
507-
Default().reportAssertionFault(defMsg, a...)
507+
Default().reportAssertionFault(defMsg, a)
508508
}
509509
}
510510

@@ -520,7 +520,7 @@ func MLen[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
520520

521521
if l != length {
522522
defMsg := fmt.Sprintf(assertionMsg+gotWantFmt, l, length)
523-
Default().reportAssertionFault(defMsg, a...)
523+
Default().reportAssertionFault(defMsg, a)
524524
}
525525
}
526526

@@ -536,7 +536,7 @@ func MLonger[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
536536

537537
if l <= length {
538538
defMsg := fmt.Sprintf(assertionMsg+gotWantLongerFmt, l, length)
539-
Default().reportAssertionFault(defMsg, a...)
539+
Default().reportAssertionFault(defMsg, a)
540540
}
541541
}
542542

@@ -552,7 +552,7 @@ func MShorter[M ~map[T]U, T comparable, U any](obj M, length int, a ...any) {
552552

553553
if l >= length {
554554
defMsg := fmt.Sprintf(assertionMsg+gotWantShorterFmt, l, length)
555-
Default().reportAssertionFault(defMsg, a...)
555+
Default().reportAssertionFault(defMsg, a)
556556
}
557557
}
558558

@@ -568,7 +568,7 @@ func CLen[C ~chan T, T any](obj C, length int, a ...any) {
568568

569569
if l != length {
570570
defMsg := fmt.Sprintf(assertionMsg+gotWantFmt, l, length)
571-
Default().reportAssertionFault(defMsg, a...)
571+
Default().reportAssertionFault(defMsg, a)
572572
}
573573
}
574574

@@ -584,7 +584,7 @@ func CLonger[C ~chan T, T any](obj C, length int, a ...any) {
584584

585585
if l <= length {
586586
defMsg := fmt.Sprintf(assertionMsg+gotWantLongerFmt, l, length)
587-
Default().reportAssertionFault(defMsg, a...)
587+
Default().reportAssertionFault(defMsg, a)
588588
}
589589
}
590590

@@ -600,7 +600,7 @@ func CShorter[C ~chan T, T any](obj C, length int, a ...any) {
600600

601601
if l >= length {
602602
defMsg := fmt.Sprintf(assertionMsg+gotWantShorterFmt, l, length)
603-
Default().reportAssertionFault(defMsg, a...)
603+
Default().reportAssertionFault(defMsg, a)
604604
}
605605
}
606606

@@ -612,7 +612,7 @@ func MKeyExists[M ~map[T]U, T comparable, U any](obj M, key T, a ...any) (val U)
612612

613613
if !ok {
614614
defMsg := fmt.Sprintf(assertionMsg+": key '%v' doesn't exist", key)
615-
Default().reportAssertionFault(defMsg, a...)
615+
Default().reportAssertionFault(defMsg, a)
616616
}
617617
return val
618618
}
@@ -623,7 +623,7 @@ func MKeyExists[M ~map[T]U, T comparable, U any](obj M, key T, a ...any) (val U)
623623
func NotEmpty(obj string, a ...any) {
624624
if obj == "" {
625625
defMsg := assertionMsg + ": string shouldn't be empty"
626-
Default().reportAssertionFault(defMsg, a...)
626+
Default().reportAssertionFault(defMsg, a)
627627
}
628628
}
629629

@@ -633,7 +633,7 @@ func NotEmpty(obj string, a ...any) {
633633
func Empty(obj string, a ...any) {
634634
if obj != "" {
635635
defMsg := assertionMsg + ": string should be empty"
636-
Default().reportAssertionFault(defMsg, a...)
636+
Default().reportAssertionFault(defMsg, a)
637637
}
638638
}
639639

@@ -648,7 +648,7 @@ func SNotEmpty[S ~[]T, T any](obj S, a ...any) {
648648

649649
if l == 0 {
650650
defMsg := assertionMsg + ": slice shouldn't be empty"
651-
Default().reportAssertionFault(defMsg, a...)
651+
Default().reportAssertionFault(defMsg, a)
652652
}
653653
}
654654

@@ -665,7 +665,7 @@ func MNotEmpty[M ~map[T]U, T comparable, U any](obj M, a ...any) {
665665

666666
if l == 0 {
667667
defMsg := assertionMsg + ": map shouldn't be empty"
668-
Default().reportAssertionFault(defMsg, a...)
668+
Default().reportAssertionFault(defMsg, a)
669669
}
670670
}
671671

@@ -681,7 +681,7 @@ func MNotEmpty[M ~map[T]U, T comparable, U any](obj M, a ...any) {
681681
func NoError(err error, a ...any) {
682682
if err != nil {
683683
defMsg := "NoError:" + assertionMsg + conCatErrStr + err.Error()
684-
Default().reportAssertionFault(defMsg, a...)
684+
Default().reportAssertionFault(defMsg, a)
685685
}
686686
}
687687

@@ -691,7 +691,7 @@ func NoError(err error, a ...any) {
691691
func Error(err error, a ...any) {
692692
if err == nil {
693693
defMsg := "Error:" + assertionMsg + ": missing error"
694-
Default().reportAssertionFault(defMsg, a...)
694+
Default().reportAssertionFault(defMsg, a)
695695
}
696696
}
697697

@@ -701,7 +701,7 @@ func Error(err error, a ...any) {
701701
func Zero[T Number](val T, a ...any) {
702702
if val != 0 {
703703
defMsg := fmt.Sprintf(assertionMsg+": got '%v', want (== '0')", val)
704-
Default().reportAssertionFault(defMsg, a...)
704+
Default().reportAssertionFault(defMsg, a)
705705
}
706706
}
707707

@@ -711,7 +711,7 @@ func Zero[T Number](val T, a ...any) {
711711
func NotZero[T Number](val T, a ...any) {
712712
if val == 0 {
713713
defMsg := fmt.Sprintf(assertionMsg+": got '%v', want (!= 0)", val)
714-
Default().reportAssertionFault(defMsg, a...)
714+
Default().reportAssertionFault(defMsg, a)
715715
}
716716
}
717717

@@ -793,7 +793,7 @@ func newDefInd(v string) defInd {
793793
func combineArgs(format string, a []any) []any {
794794
args := make([]any, 1, len(a)+1)
795795
args[0] = format
796-
args = append(args, a...)
796+
args = append(args, a)
797797
return args
798798
}
799799

assert/asserter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const officialTestOutputPrefix = " "
5454
// Note. We use the pattern where we build defaultMsg argument reaady in cases
5555
// like 'got: X, want: Y'. This hits two birds with one stone: we have automatic
5656
// and correct assert messages, and we can add information to it if we want to.
57-
func (asserter Asserter) reportAssertionFault(defaultMsg string, a ...any) {
57+
func (asserter Asserter) reportAssertionFault(defaultMsg string, a []any) {
5858
if asserter.hasStackTrace() {
5959
if asserter.isUnitTesting() {
6060
// Note. that the assert in the test function is printed in

0 commit comments

Comments
 (0)