Skip to content

Commit

Permalink
messageID: add NewSafeID testcase
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
  • Loading branch information
zchee committed Feb 14, 2022
1 parent fb30ed3 commit 1265b2e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions messageID_test.go
Expand Up @@ -4,6 +4,25 @@ import (
"testing"
)

func TestNewSafeID(t *testing.T) {
idgen := NewSafeID(1)
id1 := idgen.Next()
id2 := idgen.Next()
if id1 == id2 {
t.Fatalf("id1 and id2 are same: id1: %d, id2: %d", id1, id2)
}

idgen = NewSafeID(100)
id100 := idgen.Next()
id101 := idgen.Next()
if id2 == id100 {
t.Fatalf("except id2 and id100 not same: id2: %d, id101: %d", id2, id100)
}
if id100 == id101 {
t.Fatalf("id1 and id2 are same: id100: %d, id101: %d", id100, id101)
}
}

var id int

func BenchmarkNewSafeID(b *testing.B) {
Expand Down

0 comments on commit 1265b2e

Please sign in to comment.