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

     1  package should
     2  
     3  import (
     4  	"github.com/stretchr/testify/assert"
     5  	"github.com/v2pro/plz/test"
     6  	"runtime"
     7  )
     8  
     9  //go:noinline
    10  func Equal(expected interface{}, actual interface{}) {
    11  	t := test.CurrentT()
    12  	if assert.Equal(t, expected, actual) {
    13  		return
    14  	}
    15  	test.Helper()
    16  	_, file, line, ok := runtime.Caller(1)
    17  	if !ok {
    18  		t.Error("check failed")
    19  		return
    20  	}
    21  	t.Error(test.ExtractFailedLines(file, line))
    22  }
    23  
    24  //go:noinline
    25  func AssertEqual(expected interface{}, actual interface{}) {
    26  	t := test.CurrentT()
    27  	if assert.Equal(t, expected, actual) {
    28  		return
    29  	}
    30  	test.Helper()
    31  	_, file, line, ok := runtime.Caller(1)
    32  	if !ok {
    33  		t.Error("check failed")
    34  		return
    35  	}
    36  	t.Error(test.ExtractFailedLines(file, line))
    37  }