mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 16:57:06 +08:00
18 lines
349 B
Go
18 lines
349 B
Go
package idgenerator
|
|
|
|
import "testing"
|
|
|
|
func TestMGenerator(t *testing.T) {
|
|
gen := MakeGenerator("a")
|
|
ids := make(map[int64]struct{})
|
|
size := int(1e6)
|
|
for i := 0; i < size; i++ {
|
|
id := gen.NextId()
|
|
_, ok := ids[id]
|
|
if ok {
|
|
t.Errorf("duplicated id: %d, time: %d, seq: %d", id, gen.lastStamp, gen.sequence)
|
|
}
|
|
ids[id] = struct{}{}
|
|
}
|
|
}
|