@@ -9,30 +9,40 @@ import (
99// DeepEqual tests the deep equality between actual and expect parameters. It'll set the result to
1010// fail if they are not deeply equal, and it doesn't stop the execution.
1111func (a * Assertion ) DeepEqual (actual , expect any , message ... string ) error {
12+ a .Helper ()
13+
1214 return tryDeepEqual (a .T , false , actual , expect , message ... )
1315}
1416
1517// DeepEqualNow tests the deep equality between actual and expect parameters, and it'll stop the
1618// execution if they are not deeply equal.
1719func (a * Assertion ) DeepEqualNow (actual , expect any , message ... string ) error {
20+ a .Helper ()
21+
1822 return tryDeepEqual (a .T , true , actual , expect , message ... )
1923}
2024
2125// NotDeepEqual tests the deep inequality between actual and expected parameters. It'll set the
2226// result to fail if they are deeply equal, but it doesn't stop the execution.
2327func (a * Assertion ) NotDeepEqual (actual , expect any , message ... string ) error {
28+ a .Helper ()
29+
2430 return tryNotDeepEqual (a .T , false , actual , expect , message ... )
2531}
2632
2733// NotDeepEqualNow tests the deep inequality between actual and expected parameters, and it'll stop
2834// the execution if they are deeply equal.
2935func (a * Assertion ) NotDeepEqualNow (actual , expect any , message ... string ) error {
36+ a .Helper ()
37+
3038 return tryNotDeepEqual (a .T , true , actual , expect , message ... )
3139}
3240
3341// tryDeepEqual try to testing the deeply equality between actual and expect values, and it'll
3442// fail if the values are not deeply equal.
3543func tryDeepEqual (t * testing.T , failedNow bool , actual , expect any , message ... string ) error {
44+ t .Helper ()
45+
3646 if reflect .DeepEqual (actual , expect ) {
3747 return nil
3848 }
@@ -46,6 +56,8 @@ func tryDeepEqual(t *testing.T, failedNow bool, actual, expect any, message ...s
4656// tryNotDeepEqual try to testing the deeply inequality between actual and expect values, and it'll
4757// fail if the values are deeply equal.
4858func tryNotDeepEqual (t * testing.T , failedNow bool , actual , expect any , message ... string ) error {
59+ t .Helper ()
60+
4961 if ! reflect .DeepEqual (actual , expect ) {
5062 return nil
5163 }
@@ -60,6 +72,8 @@ func tryNotDeepEqual(t *testing.T, failedNow bool, actual, expect any, message .
6072// always return false if the value is a bool, an integer, a floating number, a complex, or a
6173// string.
6274func (a * Assertion ) Nil (val any , message ... string ) error {
75+ a .Helper ()
76+
6377 return tryNil (a .T , false , val , message ... )
6478}
6579
@@ -69,13 +83,17 @@ func (a *Assertion) Nil(val any, message ...string) error {
6983//
7084// This function will set the result to fail, and stop the execution if the value is not nil.
7185func (a * Assertion ) NilNow (val any , message ... string ) error {
86+ a .Helper ()
87+
7288 return tryNil (a .T , true , val , message ... )
7389}
7490
7591// NotNil tests whether a value is nil or not, and it'll fail when the value is nil. It will
7692// always return true if the value is a bool, an integer, a floating number, a complex, or a
7793// string.
7894func (a * Assertion ) NotNil (val any , message ... string ) error {
95+ a .Helper ()
96+
7997 return tryNotNil (a .T , false , val , message ... )
8098}
8199
@@ -85,11 +103,15 @@ func (a *Assertion) NotNil(val any, message ...string) error {
85103//
86104// This function will set the result to fail, and stop the execution if the value is nil.
87105func (a * Assertion ) NotNilNow (val any , message ... string ) error {
106+ a .Helper ()
107+
88108 return tryNotNil (a .T , true , val , message ... )
89109}
90110
91111// tryNil try to testing a value is nil or not, and it'll fail the value is nil.
92112func tryNil (t * testing.T , failedNow bool , val any , message ... string ) error {
113+ t .Helper ()
114+
93115 if isNil (val ) {
94116 return nil
95117 }
@@ -102,6 +124,8 @@ func tryNil(t *testing.T, failedNow bool, val any, message ...string) error {
102124
103125// tryNotNil try to testing a value is nil or not, and it'll fail the value is not nil.
104126func tryNotNil (t * testing.T , failedNow bool , val any , message ... string ) error {
127+ t .Helper ()
128+
105129 if ! isNil (val ) {
106130 return nil
107131 }
0 commit comments