| 220 | } |
| 221 | |
| 222 | func 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 | |
| 243 | func TestLRU_Values(t *testing.T) { |
| 244 | lc := lru.NewLRU[string, string](3, nil, 0) |