github.com/nikandfor/loc@v0.5.1/unsafe_test.go (about)

     1  package loc
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestLocation3(t *testing.T) {
    10  	t.Parallel()
    11  
    12  	testInline(t)
    13  }
    14  
    15  func testInline(t *testing.T) {
    16  	t.Helper()
    17  
    18  	testLocation3(t)
    19  }
    20  
    21  func testLocation3(t *testing.T) {
    22  	t.Helper()
    23  
    24  	l := Caller(1)
    25  	assert.Equal(t, "unsafe_test.go:18", l.String())
    26  }
    27  
    28  func TestLocationZero(t *testing.T) {
    29  	t.Parallel()
    30  
    31  	var l PC
    32  
    33  	entry := l.FuncEntry()
    34  	assert.Equal(t, PC(0), entry)
    35  
    36  	entry = PC(100).FuncEntry()
    37  	assert.Equal(t, PC(0), entry)
    38  
    39  	name, file, line := l.NameFileLine()
    40  	assert.Equal(t, "", name)
    41  	assert.Equal(t, "", file)
    42  	assert.Equal(t, 0, line)
    43  }