MCPcopy Index your code
hub / github.com/aceld/zinx / TestClearWithFuncLock

Function TestClearWithFuncLock

zutils/shard_lock_map_test.go:704–720  ·  view source on GitHub ↗

TestClearWithFuncLock tests the ClearWithFuncLock method

(t *testing.T)

Source from the content-addressed store, hash-verified

702
703// TestClearWithFuncLock tests the ClearWithFuncLock method
704func TestClearWithFuncLock(t *testing.T) {
705 slm := NewShardLockMaps()
706 slm.Set("key1", "value1")
707 slm.Set("key2", "value2")
708
709 var clearedKeys []string
710 slm.ClearWithFuncLock(func(key string, val interface{}) {
711 clearedKeys = append(clearedKeys, key)
712 })
713
714 if len(clearedKeys) != 2 {
715 t.Error("Expected 2 keys to be cleared")
716 }
717 if slm.Count() != 0 {
718 t.Error("Expected map to be empty after ClearWithFuncLock")
719 }
720}

Callers

nothing calls this directly

Calls 5

SetMethod · 0.95
ClearWithFuncLockMethod · 0.95
CountMethod · 0.95
NewShardLockMapsFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected