MCPcopy
hub / github.com/coocood/freecache / TestSetAndGet

Function TestSetAndGet

cache_test.go:1245–1263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1243}
1244
1245func TestSetAndGet(t *testing.T) {
1246 cache := NewCache(1024)
1247 key := []byte("abcd")
1248 val1 := []byte("efgh")
1249
1250 _, found, _ := cache.SetAndGet(key, val1, 0)
1251 if found == true {
1252 t.Fatalf("SetAndGet unexpected found data")
1253 }
1254
1255 val2 := []byte("ijkl")
1256 rval, found, _ := cache.SetAndGet(key, val2, 0)
1257 if found == false {
1258 t.Fatalf("SetAndGet expected found data")
1259 }
1260 if string(val1) != string(rval) {
1261 t.Fatalf("SetAndGet expected SetAndGet %s: got %s", string(val1), string(rval))
1262 }
1263}
1264
1265func TestUpdate(t *testing.T) {
1266 testName := "Update"

Callers

nothing calls this directly

Calls 2

SetAndGetMethod · 0.95
NewCacheFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…