TestShardingDelete tests the Delete method by adding and then removing five values.
(t *testing.T)
| 108 | |
| 109 | // TestShardingDelete tests the Delete method by adding and then removing five values. |
| 110 | func TestShardingDelete(t *testing.T) { |
| 111 | const BUCKETS = 17 |
| 112 | |
| 113 | sMap := NewShardedMap[string, int](BUCKETS) |
| 114 | |
| 115 | truthMap := map[string]int{ |
| 116 | "alpha": 1, |
| 117 | "beta": 2, |
| 118 | "gamma": 3, |
| 119 | "delta": 4, |
| 120 | "epsilon": 5, |
| 121 | } |
| 122 | |
| 123 | for k, v := range truthMap { |
| 124 | sMap.Set(k, v) |
| 125 | } |
| 126 | |
| 127 | keys := sMap.Keys() |
| 128 | for _, key := range keys { |
| 129 | sMap.Delete(key) |
| 130 | } |
| 131 | |
| 132 | if len(sMap.Keys()) != 0 { |
| 133 | t.Error("Deletion failure") |
| 134 | } |
| 135 | } |