diff --git a/pkg/syncmap/syncmap_test.go b/pkg/syncmap/syncmap_test.go index d3b57f153..acc9f2c5c 100644 --- a/pkg/syncmap/syncmap_test.go +++ b/pkg/syncmap/syncmap_test.go @@ -21,6 +21,8 @@ import ( "testing" "time" + "github.com/dragonflyoss/Dragonfly/pkg/atomiccount" + "github.com/go-check/check" "github.com/willf/bitset" ) @@ -131,3 +133,15 @@ func (suite *SyncMapUtilSuite) TestGetAsTime(c *check.C) { result, _ := mmap.GetAsTime("aaa") c.Check(result, check.DeepEquals, expected) } + +func (suite *SyncMapUtilSuite) TestGetAsAtomicInt(c *check.C) { + expected := atomiccount.NewAtomicInt(10) + mmap := NewSyncMap() + mmap.Add("aaa", expected) + + result, _ := mmap.GetAsAtomicInt("aaa") + c.Check(result, check.DeepEquals, expected) + + result, err := mmap.GetAsAtomicInt("nonexist") + c.Check(err, check.NotNil) +}