From 575e79bb2f0f889a7a0136a791b00a2eddfca617 Mon Sep 17 00:00:00 2001 From: YamiOdymel Date: Mon, 7 Sep 2020 18:24:39 +0800 Subject: [PATCH] TestGoroutine --- trillium_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/trillium_test.go b/trillium_test.go index 5e98bd6..1300417 100644 --- a/trillium_test.go +++ b/trillium_test.go @@ -29,6 +29,40 @@ func TestTimeout(t *testing.T) { } } +func TestGoroutine(t *testing.T) { + assert := assert.New(t) + tri := New(DefaultConfig()) + + done := make(chan bool, 2) + go func() { + var i int + for { + if i > 512 { + done <- true + break + } + i++ + + _, err := tri.Generate() + assert.NoError(err) + } + }() + go func() { + var i int + for { + if i > 512 { + done <- true + break + } + i++ + + _, err := tri.Generate() + assert.NoError(err) + } + }() + <-done +} + func BenchmarkUint64(b *testing.B) { t := New(DefaultConfig()) b.ReportAllocs()