(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestNewV6FromTimeGeneratesUniqueUUIDs(t *testing.T) { |
| 43 | now := time.Now() |
| 44 | ids := make([]string, 0) |
| 45 | runs := 26000 |
| 46 | |
| 47 | for i := 0; i < runs; i++ { |
| 48 | now = now.Add(time.Nanosecond) // Without this line, we can generate only 16384 UUIDs for the same timestamp |
| 49 | id, err := NewV6WithTime(&now) |
| 50 | if err != nil { |
| 51 | t.Errorf("NewV6WithTime returned unexpected error %v", err) |
| 52 | } |
| 53 | if id.Version() != 6 { |
| 54 | t.Errorf("got %d, want version 6", id.Version()) |
| 55 | } |
| 56 | |
| 57 | // Make sure we add only unique values |
| 58 | if !contains(t, ids, id.String()) { |
| 59 | ids = append(ids, id.String()) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // Check we added all the UIDs |
| 64 | if len(ids) != runs { |
| 65 | t.Errorf("got %d UUIDs, want %d", len(ids), runs) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | func BenchmarkNewV6WithTime(b *testing.B) { |
| 70 | b.RunParallel(func(pb *testing.PB) { |
nothing calls this directly
no test coverage detected