added code
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
package idg
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIDGenerator(t *testing.T) {
|
||||
cache := make(map[string]bool)
|
||||
var cur string
|
||||
gg := NewIdGenerator()
|
||||
go gg.Run()
|
||||
for i := 0; i < 10000; i++ {
|
||||
cur = gg.Hash()
|
||||
if _, ok := cache[cur]; ok {
|
||||
t.Errorf("unexpected duplicate key")
|
||||
}
|
||||
cache[cur] = true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user