From 10ffb57eed7624c92d95af561af97c635d407809 Mon Sep 17 00:00:00 2001 From: alin104n Date: Sun, 9 Apr 2017 07:57:28 +0300 Subject: [PATCH] Added simple Counter test --- utils/coreutils_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/utils/coreutils_test.go b/utils/coreutils_test.go index 619a8337a..e7b87737a 100644 --- a/utils/coreutils_test.go +++ b/utils/coreutils_test.go @@ -762,6 +762,20 @@ Date: Fri Dec 30 19:48:09 2016 +0100 } func TestCounter(t *testing.T) { + var cmax int64 = 10000 + var i int64 + cnter := NewCounter(0, cmax) + for i = 1; i <= cmax; i++ { + if i != cnter.Next() { + t.Error("Counter has unexpected value") + } + } + if cnter.Next() != 0 { + t.Error("Counter did not reset") + } +} + +func TestCounterConcurrent(t *testing.T) { var nmax int64 = 10000 ch := make(chan int64, nmax) wg := new(sync.WaitGroup)