16 lines
381 B
Go
16 lines
381 B
Go
package idgen
|
|
|
|
import "testing"
|
|
|
|
// TestInt64GeneratorProducesIncreasingIDs 锁定用户长 ID 的单进程单调性。
|
|
func TestInt64GeneratorProducesIncreasingIDs(t *testing.T) {
|
|
generator := NewInt64Generator(1)
|
|
|
|
first := generator.NewInt64()
|
|
second := generator.NewInt64()
|
|
|
|
if second <= first {
|
|
t.Fatalf("expected increasing ids: first=%d second=%d", first, second)
|
|
}
|
|
}
|