github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/test/should/nil.go (about)

     1  package should
     2  
     3  import (
     4  	"github.com/v2pro/plz/test"
     5  	"github.com/v2pro/plz/test/testify/assert"
     6  	"runtime"
     7  )
     8  
     9  func Nil(actual interface{}) {
    10  	t := test.CurrentT()
    11  	if assert.Nil(t, actual) {
    12  		return
    13  	}
    14  	test.Helper()
    15  	_, file, line, ok := runtime.Caller(1)
    16  	if !ok {
    17  		t.Error("check failed")
    18  		return
    19  	}
    20  	t.Error(test.ExtractFailedLines(file, line))
    21  }
    22  
    23  func AssertNil(actual interface{}) {
    24  	t := test.CurrentT()
    25  	if assert.Nil(t, actual) {
    26  		return
    27  	}
    28  	test.Helper()
    29  	_, file, line, ok := runtime.Caller(1)
    30  	if !ok {
    31  		t.Error("check failed")
    32  		return
    33  	}
    34  	t.Error(test.ExtractFailedLines(file, line))
    35  }
    36  
    37  func NotNil(actual interface{}) {
    38  	t := test.CurrentT()
    39  	if assert.NotNil(t, actual) {
    40  		return
    41  	}
    42  	test.Helper()
    43  	_, file, line, ok := runtime.Caller(1)
    44  	if !ok {
    45  		t.Error("check failed")
    46  		return
    47  	}
    48  	t.Error(test.ExtractFailedLines(file, line))
    49  }
    50  
    51  func AssertNotNil(actual interface{}) {
    52  	t := test.CurrentT()
    53  	if assert.NotNil(t, actual) {
    54  		return
    55  	}
    56  	test.Helper()
    57  	_, file, line, ok := runtime.Caller(1)
    58  	if !ok {
    59  		t.Error("check failed")
    60  		return
    61  	}
    62  	t.Error(test.ExtractFailedLines(file, line))
    63  }