github.com/haraldrudell/parl@v0.4.176/goid_test.go (about)

     1  /*
     2  © 2023–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package parl
     7  
     8  import (
     9  	"strconv"
    10  	"testing"
    11  )
    12  
    13  func Test_goID(t *testing.T) {
    14  
    15  	var threadID ThreadID
    16  	var err error
    17  	var id int
    18  
    19  	threadID = goID()
    20  	if !threadID.IsValid() {
    21  		t.Errorf("threadID not valid: %d", threadID)
    22  	}
    23  	s := threadID.String()
    24  	if s == "" {
    25  		t.Error("threadID.String empty string")
    26  	}
    27  	if id, err = strconv.Atoi(s); err != nil {
    28  		t.Errorf("strconv.Atoi failed: %q", s)
    29  	}
    30  	if id < 1 {
    31  		t.Errorf("unexpected id: %d exp 1…", id)
    32  	}
    33  }