github.com/haraldrudell/parl@v0.4.176/unique-id-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 func TestUniqueIDUint64(t *testing.T) { 11 var v1 uint64 = 1 12 var v2 uint64 = 2 13 14 var v uint64 15 16 var generator UniqueIDUint64 17 if v = generator.ID(); v != v1 { 18 t.Errorf("bad1 %d exp %d", v, v1) 19 } 20 if v = generator.ID(); v != v2 { 21 t.Errorf("bad2 %d exp %d", v, v2) 22 } 23 24 // v.String undefined (type uint64 has no field or method String) 25 //v.String() 26 27 // conversion from uint64 to string yields a string of one rune, not a string of digits 28 // (did you mean fmt.Sprint(x)?) 29 //_ = string(v) 30 31 // format %s has arg v of wrong type uint64, see also https://pkg.go.dev/fmt#hdr-Printing 32 //t.Logf("print using %%s: %s", v) 33 34 // print using %d: 2 35 t.Logf("print using %%d: %d", v) 36 37 // The default format for %v is: 38 // uint, uint8 etc.: %d, %#x if printed with %#v 39 // print using %v: 2 40 t.Logf("print using %%v: %v", v) 41 42 //t.Fail() 43 }