github.com/haraldrudell/parl@v0.4.176/g0/thread-safe-thread-data_test.go (about)

     1  /*
     2  © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package g0
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/haraldrudell/parl/pdebug"
    12  )
    13  
    14  func TestThreadDataWrap(t *testing.T) {
    15  	stack := pdebug.NewStack(0)
    16  
    17  	var threadDataWrap ThreadSafeThreadData
    18  	var threadData *ThreadData
    19  
    20  	threadDataWrap = ThreadSafeThreadData{}
    21  	if threadDataWrap.HaveThreadID() {
    22  		t.Error("haveThreadID true")
    23  	}
    24  
    25  	var creator, _, _ = stack.Creator()
    26  	threadDataWrap.Update(
    27  		stack.ID(),
    28  		creator,
    29  		stack.GoFunction(),
    30  		"",
    31  	)
    32  	if threadDataWrap.ThreadID() != stack.ID() {
    33  		t.Errorf("bad ID %q exp %q", threadDataWrap.ThreadID(), stack.ID())
    34  	}
    35  	threadData = threadDataWrap.Get()
    36  	_ = threadData
    37  	threadDataWrap.SetCreator(creator)
    38  }