You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
309B

  1. package server
  2. import (
  3. "testing"
  4. )
  5. func TestIDGenerator(t *testing.T) {
  6. cache := make(map[string]bool)
  7. var cur string
  8. gg := NewIdGenerator()
  9. go gg.Run()
  10. for i := 0; i < 10000; i++ {
  11. cur = gg.Hash()
  12. if _, ok := cache[cur]; ok {
  13. t.Errorf("unexpected duplicate key")
  14. }
  15. cache[cur] = true
  16. }
  17. }