From ed1db9739620f56e292e97a8ce497a52609b9be0 Mon Sep 17 00:00:00 2001 From: nxshock Date: Wed, 3 Feb 2021 23:28:12 +0500 Subject: [PATCH] Add basic test --- gwp_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gwp_test.go diff --git a/gwp_test.go b/gwp_test.go new file mode 100644 index 0000000..84342ff --- /dev/null +++ b/gwp_test.go @@ -0,0 +1,27 @@ +package gwp + +import ( + "sync/atomic" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestBasic(t *testing.T) { + for i := 0; i < 10; i++ { + wp := New(i) + + count := new(int64) + + for j := 0; j < 100; j++ { + wp.Add(func() error { + atomic.AddInt64(count, 1) + return nil + }) + } + + wp.CloseAndWait() + + assert.EqualValues(t, 100, *count) + } +}