MCPcopy Create free account
hub / github.com/cloud-native-go/examples / TestShardingDelete

Function TestShardingDelete

ch04/sharding_test.go:110–135  ·  view source on GitHub ↗

TestShardingDelete tests the Delete method by adding and then removing five values.

(t *testing.T)

Source from the content-addressed store, hash-verified

108
109// TestShardingDelete tests the Delete method by adding and then removing five values.
110func 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}

Callers

nothing calls this directly

Calls 3

SetMethod · 0.80
KeysMethod · 0.80
DeleteMethod · 0.65

Tested by

no test coverage detected