-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUniqueId_test.go
More file actions
41 lines (37 loc) · 843 Bytes
/
UniqueId_test.go
File metadata and controls
41 lines (37 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package u_test
import (
"fmt"
"github.com/ssgo/u"
"testing"
)
//func TestId(t *testing.T) {
// for _, nx := range []string{"99u", "UUU", "999u", "UUUU", "9999u", "UUUUU", "99999u", "UUUUUU"} {
// fmt.Println(nx, u.DecodeInt([]byte(nx)))
// }
// for i:=0; i<10; i++ {
// dd := u.ShortUniqueId()
// fmt.Println(dd, len(dd))
// }
//}
func TestUniqueId(t *testing.T) {
fmt.Println(u.UniqueId())
uids := map[string]bool{}
for i := 0; i < 100000; i++ {
uid := u.UniqueId()
if uids[uid] {
t.Error("unique id repeated ", uids, uid)
}
uids[uid] = true
}
}
func TestShortUniqueId(t *testing.T) {
fmt.Println(u.ShortUniqueId(), len(u.ShortUniqueId()))
uids := map[string]bool{}
for i := 0; i < 100000; i++ {
uid := u.UniqueId()
if uids[uid] {
t.Error("short unique id repeated ", uids, uid)
}
uids[uid] = true
}
}