MCPcopy
hub / github.com/go-gorm/gorm / TestLRUEdgeCases

Function TestLRUEdgeCases

tests/lru_test.go:222–241  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

220}
221
222func TestLRUEdgeCases(t *testing.T) {
223 lc := lru.NewLRU[string, *string](2, nil, 0)
224
225 // Adding a nil value
226 lc.Add("key1", nil)
227
228 value, exists := lc.Get("key1")
229 if value != nil || !exists {
230 t.Fatalf("unexpected value or existence flag for key1: value=%v, exists=%v", value, exists)
231 }
232
233 // Adding an entry with the same key but different value
234 newVal := "val1"
235 lc.Add("key1", &newVal)
236
237 value, exists = lc.Get("key1")
238 if value != &newVal || !exists {
239 t.Fatalf("unexpected value or existence flag for key1: value=%v, exists=%v", value, exists)
240 }
241}
242
243func TestLRU_Values(t *testing.T) {
244 lc := lru.NewLRU[string, string](3, nil, 0)

Callers

nothing calls this directly

Calls 3

NewLRUFunction · 0.92
AddMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected