Skip to content

Commit 361703f

Browse files
committed
更新
1 parent 3cc3ef2 commit 361703f

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

tool/test/assert.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...any)
194194
// EqualValues asserts that two objects are equal or convertible to the larger
195195
// type and equal.
196196
//
197-
// assert.EqualValues(t, uint32(123), int32(123))
197+
// test.EqualValues(t, uint32(123), int32(123))
198198
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
199199
if h, ok := t.(tHelper); ok {
200200
h.Helper()
@@ -218,8 +218,8 @@ func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interfa
218218
// Exported int
219219
// notExported int
220220
// }
221-
// assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
222-
// assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
221+
// test.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
222+
// test.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
223223
func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
224224
if h, ok := t.(tHelper); ok {
225225
h.Helper()
@@ -247,7 +247,7 @@ func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ..
247247

248248
// NotEqual asserts that the specified values are NOT equal.
249249
//
250-
// assert.NotEqual(t, obj1, obj2)
250+
// test.NotEqual(t, obj1, obj2)
251251
func NotEqual(t TestingT, expected, actual any, msgAndArgs ...any) bool {
252252
if h, ok := t.(tHelper); ok {
253253
h.Helper()
@@ -268,7 +268,7 @@ func NotEqual(t TestingT, expected, actual any, msgAndArgs ...any) bool {
268268

269269
// NotEqualValues asserts that two objects are not equal even when converted to the same type
270270
//
271-
// assert.NotEqualValues(t, obj1, obj2)
271+
// test.NotEqualValues(t, obj1, obj2)
272272
func NotEqualValues(t TestingT, expected, actual any, msgAndArgs ...interface{}) bool {
273273
if h, ok := t.(tHelper); ok {
274274
h.Helper()
@@ -323,7 +323,7 @@ func NotSame(t TestingT, expected, actual any, msgAndArgs ...any) bool {
323323

324324
// Exactly asserts that two objects are equal in value and type.
325325
//
326-
// assert.Exactly(t, int32(123), int64(123))
326+
// test.Exactly(t, int32(123), int64(123))
327327
func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
328328
if h, ok := t.(tHelper); ok {
329329
h.Helper()
@@ -342,7 +342,7 @@ func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
342342

343343
// Nil asserts that the specified object is nil.
344344
//
345-
// assert.Nil(t, err)
345+
// test.Nil(t, err)
346346
func Nil(t TestingT, object any, msgAndArgs ...any) bool {
347347
if isNil(object) {
348348
return true
@@ -373,7 +373,7 @@ func NotNil(t TestingT, object any, msgAndArgs ...any) bool {
373373
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
374374
// a slice or a channel with len == 0.
375375
//
376-
// assert.Empty(t, obj)
376+
// test.Empty(t, obj)
377377
func Empty(t TestingT, object any, msgAndArgs ...any) bool {
378378
pass := isEmpty(object)
379379
if !pass {
@@ -391,8 +391,8 @@ func Empty(t TestingT, object any, msgAndArgs ...any) bool {
391391
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
392392
// a slice or a channel with len == 0.
393393
//
394-
// if assert.NotEmpty(t, obj) {
395-
// assert.Equal(t, "two", obj[1])
394+
// if test.NotEmpty(t, obj) {
395+
// test.Equal(t, "two", obj[1])
396396
// }
397397
func NotEmpty(t TestingT, object any, msgAndArgs ...any) bool {
398398
pass := !isEmpty(object)
@@ -422,7 +422,7 @@ func getLen(x interface{}) (length int, ok bool) {
422422
// Len asserts that the specified object has specific length.
423423
// Len also fails if the object has a type that len() not accept.
424424
//
425-
// assert.Len(t, mySlice, 3)
425+
// test.Len(t, mySlice, 3)
426426
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool {
427427
if h, ok := t.(tHelper); ok {
428428
h.Helper()
@@ -442,7 +442,7 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{})
442442

443443
// True asserts that the specified value is true.
444444
//
445-
// assert.True(t, myBool)
445+
// test.True(t, myBool)
446446
func True(t TestingT, value bool, msgAndArgs ...any) bool {
447447
if !value {
448448
if h, ok := t.(tHelper); ok {
@@ -458,7 +458,7 @@ func True(t TestingT, value bool, msgAndArgs ...any) bool {
458458

459459
// False asserts that the specified value is false.
460460
//
461-
// assert.False(t, myBool)
461+
// test.False(t, myBool)
462462
func False(t TestingT, value bool, msgAndArgs ...any) bool {
463463
if value {
464464
if h, ok := t.(tHelper); ok {
@@ -517,9 +517,9 @@ func containsElement(list interface{}, element interface{}) (ok, found bool) {
517517
// Contains asserts that the specified string, list(array, slice...) or map contains the
518518
// specified substring or element.
519519
//
520-
// assert.Contains(t, "Hello World", "World")
521-
// assert.Contains(t, ["Hello", "World"], "World")
522-
// assert.Contains(t, {"Hello": "World"}, "Hello")
520+
// test.Contains(t, "Hello World", "World")
521+
// test.Contains(t, ["Hello", "World"], "World")
522+
// test.Contains(t, {"Hello": "World"}, "Hello")
523523
func Contains(t TestingT, s, contains any, msgAndArgs ...any) bool {
524524
if h, ok := t.(tHelper); ok {
525525
h.Helper()
@@ -541,9 +541,9 @@ func Contains(t TestingT, s, contains any, msgAndArgs ...any) bool {
541541
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
542542
// specified substring or element.
543543
//
544-
// assert.NotContains(t, "Hello World", "Earth")
545-
// assert.NotContains(t, ["Hello", "World"], "Earth")
546-
// assert.NotContains(t, {"Hello": "World"}, "Earth")
544+
// test.NotContains(t, "Hello World", "Earth")
545+
// test.NotContains(t, ["Hello", "World"], "Earth")
546+
// test.NotContains(t, {"Hello": "World"}, "Earth")
547547
func NotContains(t TestingT, s, contains any, msgAndArgs ...any) bool {
548548
if h, ok := t.(tHelper); ok {
549549
h.Helper()
@@ -565,8 +565,8 @@ func NotContains(t TestingT, s, contains any, msgAndArgs ...any) bool {
565565
// Subset asserts that the specified list(array, slice...) or map contains all
566566
// elements given in the specified subset list(array, slice...) or map.
567567
//
568-
// assert.Subset(t, [1, 2, 3], [1, 2])
569-
// assert.Subset(t, {"x": 1, "y": 2}, {"x": 1})
568+
// test.Subset(t, [1, 2, 3], [1, 2])
569+
// test.Subset(t, {"x": 1, "y": 2}, {"x": 1})
570570
func Subset(t TestingT, list, subset any, msgAndArgs ...any) (ok bool) {
571571
if h, ok := t.(tHelper); ok {
572572
h.Helper()
@@ -625,8 +625,8 @@ func Subset(t TestingT, list, subset any, msgAndArgs ...any) (ok bool) {
625625
// contain all elements given in the specified subset list(array, slice...) or
626626
// map.
627627
//
628-
// assert.NotSubset(t, [1, 3, 4], [1, 2])
629-
// assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
628+
// test.NotSubset(t, [1, 3, 4], [1, 2])
629+
// test.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
630630
func NotSubset(t TestingT, list, subset any, msgAndArgs ...any) (ok bool) {
631631
if h, ok := t.(tHelper); ok {
632632
h.Helper()
@@ -853,7 +853,7 @@ func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool {
853853

854854
// WithinDuration asserts that the two times are within duration delta of each other.
855855
//
856-
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
856+
// test.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
857857
func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
858858
if h, ok := t.(tHelper); ok {
859859
h.Helper()
@@ -869,7 +869,7 @@ func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration,
869869

870870
// WithinRange asserts that a time is within a time range (inclusive).
871871
//
872-
// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
872+
// test.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
873873
func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool {
874874
if h, ok := t.(tHelper); ok {
875875
h.Helper()
@@ -908,7 +908,7 @@ func didPanic(f PanicTestFunc) (didPanic bool, message any, stack string) {
908908

909909
// Panics asserts that the code inside the specified PanicTestFunc panics.
910910
//
911-
// assert.Panics(t, func(){ GoCrazy() })
911+
// test.Panics(t, func(){ GoCrazy() })
912912
func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...any) bool {
913913
if h, ok := t.(tHelper); ok {
914914
h.Helper()
@@ -924,7 +924,7 @@ func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...any) bool {
924924
// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
925925
// the recovered panic value equals the expected panic value.
926926
//
927-
// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
927+
// test.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
928928
func PanicsWithValue(t TestingT, expected any, f PanicTestFunc, msgAndArgs ...any) bool {
929929
if h, ok := t.(tHelper); ok {
930930
h.Helper()
@@ -946,7 +946,7 @@ func PanicsWithValue(t TestingT, expected any, f PanicTestFunc, msgAndArgs ...an
946946
// panics, and that the recovered panic value is an error that satisfies the
947947
// EqualError comparison.
948948
//
949-
// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
949+
// test.PanicsWithError(t, "crazy error", func(){ GoCrazy() })
950950
func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgAndArgs ...any) bool {
951951
if h, ok := t.(tHelper); ok {
952952
h.Helper()
@@ -967,7 +967,7 @@ func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgAndArgs .
967967

968968
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
969969
//
970-
// assert.NotPanics(t, func(){ RemainCalm() })
970+
// test.NotPanics(t, func(){ RemainCalm() })
971971
func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...any) bool {
972972
if h, ok := t.(tHelper); ok {
973973
h.Helper()

0 commit comments

Comments
 (0)