1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00

更新ID生成器

This commit is contained in:
2023-10-26 14:42:23 +08:00
parent 6647f96978
commit 0d124c0b79
17 changed files with 1079 additions and 150 deletions

View File

@ -0,0 +1,34 @@
package idgenerator
import (
"testing"
)
func TestBinary(t *testing.T) {
f, _ := newBinaryFormatter(DefaultStartTimeStamp, 16, 12)
t.Log(f.maxinalMachineCode, f.maximalSequence)
}
func TestDecimal(t *testing.T) {
f, _ := newDecimalFormater(YYYYMMDDHHmmss, 4, 1)
t.Log(f.maxinalMachineCode, f.maxinalMachineCode)
t.Log(f.Format(22333, 9, false))
}
func TestDecimalMonth111(t *testing.T) {
f, _ := newDecimalFormater(YYYYMMDD, 4, 1)
t.Log(f.maxinalMachineCode, f.maxinalMachineCode)
t.Log(f.Format(233, 9, false))
}
func TestBinaryTimestamp(t *testing.T) {
f, _ := newBinaryFormatter(DefaultStartTimeStamp, 10, 4)
for i := 0; i < 100; i++ {
if i%7 == 0 {
t.Log(f.Format(int64(i), 0xF, true))
} else {
t.Log(f.Format(int64(i), 0xF, false))
}
}
}