github.com/haraldrudell/parl@v0.4.176/unique-id-typed-uint64_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 parl
     7  
     8  import "testing"
     9  
    10  type Ttype uint64
    11  
    12  var generator UniqueIDTypedUint64[Ttype]
    13  
    14  func (t Ttype) String() string { return generator.StringT(t) }
    15  func TestUniqueIDTypedUint64(t *testing.T) {
    16  	var v1 Ttype = 1
    17  	var v2 Ttype = 2
    18  
    19  	var v Ttype
    20  
    21  	if v = generator.ID(); v != v1 {
    22  		t.Errorf("bad1 %d exp %d", v, v1)
    23  	}
    24  	if v = generator.ID(); v != v2 {
    25  		t.Errorf("bad2 %d exp %d", v, v2)
    26  	}
    27  	t.Logf("type name via %%T: %T", v)
    28  
    29  	// format %s has arg v of wrong type github.com/haraldrudell/parl.T
    30  	t.Logf("value via %%s: %s", v)
    31  
    32  	t.Logf("value via %%v: %v", v)
    33  	var vNil Ttype
    34  	t.Log(generator.StringT(vNil))
    35  	//t.Fail()
    36  }