26 lines
456 B
Go
26 lines
456 B
Go
package ID
|
|
|
|
import "testing"
|
|
|
|
func TestUnique(t *testing.T) {
|
|
gen := New(0)
|
|
ids := make(map[Type]struct{})
|
|
|
|
start := gen.Next()
|
|
ids[start] = struct{}{}
|
|
|
|
for current := gen.Next(); current != start; current = gen.Next() {
|
|
if _, ok := ids[current]; ok {
|
|
t.Fatal("generator returned known id")
|
|
}
|
|
|
|
ids[current] = struct{}{}
|
|
}
|
|
|
|
if len(ids) == 1 {
|
|
t.Error("generator always returns same id")
|
|
}
|
|
|
|
t.Log("generator returned", len(ids), "ids")
|
|
}
|