github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/counter/counter_test.go (about)

     1  package counter
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmorg/murex/test/count"
     7  )
     8  
     9  func TestCounter(t *testing.T) {
    10  	count.Tests(t, 2)
    11  
    12  	mc := new(MutexCounter)
    13  	i := mc.Add()
    14  	if i != 1 {
    15  		t.Errorf("MutexCounter should eq 1: %d", i)
    16  	}
    17  
    18  	mc.Set(2)
    19  	if !mc.NotEqual(i) {
    20  		t.Errorf("MutexCounter should eq 2: %d != 2", i)
    21  	}
    22  }