add uniqueness-test

This commit is contained in:
Julian Daube 2016-09-24 16:19:36 +02:00
parent c4135d2941
commit ddc04beb33

25
generator_test.go Normal file
View File

@ -0,0 +1,25 @@
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")
}