@@ -2,6 +2,8 @@ package assert
22
33import (
44 "testing"
5+
6+ "github.com/ghosind/go-assert/internal"
57)
68
79func TestNewAssertion (t * testing.T ) {
@@ -19,9 +21,29 @@ func TestRun(t *testing.T) {
1921 isSubTestRun := false
2022
2123 a .Run ("sub test" , func (sub * Assertion ) {
22- DeepEqualNow (t , sub .Name (), "TestRun/sub_test" )
24+ EqualNow (t , sub .Name (), "TestRun/sub_test" )
2325 isSubTestRun = true
2426 })
2527
26- DeepEqualNow (t , isSubTestRun , true )
28+ TrueNow (t , isSubTestRun )
29+ }
30+
31+ func testAssertionFunction (a * Assertion , name string , fn func () error , expectSuccess bool ) {
32+ a .Helper ()
33+
34+ err := fn ()
35+ if expectSuccess {
36+ a .NilNow (err , "%s() = %v, want = nil" , name , err )
37+ } else {
38+ a .NotNilNow (err , "%s() = nil, want = error" , name )
39+ }
40+ }
41+
42+ func testAssertionNowFunction (a * Assertion , name string , fn func (), expectExit bool ) {
43+ isTerminated := internal .CheckTermination (fn )
44+ if expectExit {
45+ a .TrueNow (isTerminated , "%s() execution stopped, want do not stop" , name )
46+ } else {
47+ a .NotTrueNow (isTerminated , "%s() execution do not stopped, want stop" , name )
48+ }
2749}
0 commit comments