| 35 | } |
| 36 | |
| 37 | func TestConcurrentCountMap_Add(t *testing.T) { |
| 38 | var m CountersMap[int] |
| 39 | |
| 40 | found := m.add(42, 5) |
| 41 | require.False(t, found, "Add on new key should return false to indicate 'key not previously found'") |
| 42 | |
| 43 | v, found := m.Get(42) |
| 44 | |
| 45 | require.EqualValues(t, 5, v, "expected 5 after add") |
| 46 | require.True(t, found) |
| 47 | |
| 48 | found = m.add(42, 3) |
| 49 | require.True(t, found, "Add on existing key should return true") |
| 50 | |
| 51 | v, found = m.Get(42) |
| 52 | |
| 53 | require.EqualValues(t, 8, v, "expected 8 after second add") |
| 54 | require.True(t, found) |
| 55 | } |
| 56 | |
| 57 | func TestConcurrentCountMap_Range(t *testing.T) { |
| 58 | var m CountersMap[string] |