mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
更新ID生成器
This commit is contained in:
34
idGenerator/formater_test.go
Normal file
34
idGenerator/formater_test.go
Normal 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))
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user