MCPcopy
hub / github.com/Velocidex/velociraptor / TestSetIfAbsent

Function TestSetIfAbsent

third_party/cache/lru_cache_test.go:72–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestSetIfAbsent(t *testing.T) {
73 cache := NewLRUCache(100)
74 data := &CacheValue{0}
75 key := "key"
76 cache.SetIfAbsent(key, data)
77
78 v, ok := cache.Get(key)
79 if !ok || v.(*CacheValue) != data {
80 t.Errorf("Cache has incorrect value: %v != %v", data, v)
81 }
82
83 cache.SetIfAbsent(key, &CacheValue{1})
84
85 v, ok = cache.Get(key)
86 if !ok || v.(*CacheValue) != data {
87 t.Errorf("Cache has incorrect value: %v != %v", data, v)
88 }
89}
90
91func TestGetValueWithMultipleTypes(t *testing.T) {
92 cache := NewLRUCache(100)

Callers

nothing calls this directly

Calls 4

SetIfAbsentMethod · 0.95
GetMethod · 0.95
NewLRUCacheFunction · 0.70
ErrorfMethod · 0.45

Tested by

no test coverage detected