46 lines
674 B
Go
46 lines
674 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestID(t *testing.T) {
|
|
last := id()
|
|
for i := 0; i < 1000; i++ {
|
|
next := id()
|
|
if next <= last {
|
|
t.Error(i, last, next)
|
|
}
|
|
last = next
|
|
}
|
|
}
|
|
|
|
func TestTS(t *testing.T) {
|
|
got := int64(ts_41b())
|
|
if got != ((got << (64 - 41)) >> (64 - 41)) {
|
|
t.Error("got > 41b")
|
|
}
|
|
gotTime := time.Unix(got/100, 10*(got%100))
|
|
if time.Since(gotTime) > time.Second {
|
|
t.Error(gotTime)
|
|
}
|
|
}
|
|
|
|
func TestSeq(t *testing.T) {
|
|
last := seq_13b()
|
|
for i := 0; i < 1000; i++ {
|
|
next := seq_13b()
|
|
if next <= last {
|
|
t.Error(i, last, next)
|
|
}
|
|
last = next
|
|
}
|
|
|
|
seqV.Store(1 << 14)
|
|
got := seq_13b()
|
|
if got > 2 {
|
|
t.Error(got)
|
|
}
|
|
}
|