add uniqueness-test
This commit is contained in:
parent
c4135d2941
commit
ddc04beb33
25
generator_test.go
Normal file
25
generator_test.go
Normal 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")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user