github.com/kaiya/goutils@v1.0.1-0.20230226104005-4ae4a4dc3688/cmap/cmap_test.go (about)

     1  package cmap
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func Test_cmap_store(t *testing.T) {
     8  	cm := &ConcurrentMap{}
     9  
    10  	tests := []struct {
    11  		name  string
    12  		key   interface{}
    13  		value interface{}
    14  	}{
    15  		{
    16  			"test-string",
    17  			"key",
    18  			"value",
    19  		},
    20  		{
    21  			"test-int",
    22  			1,
    23  			2,
    24  		},
    25  		{
    26  			"test-p",
    27  			"pp",
    28  			&ConcurrentMap{},
    29  		},
    30  	}
    31  	for _, tt := range tests {
    32  		t.Run(tt.name, func(t *testing.T) {
    33  			cm.m.Store(tt.key, tt.value)
    34  			_, ok := cm.m.Load(tt.key)
    35  			if !ok {
    36  				t.Errorf("%s load error", tt.name)
    37  			}
    38  		})
    39  	}
    40  }