(t *testing.T)
| 349 | } |
| 350 | |
| 351 | func TestLRUConcurrency(t *testing.T) { |
| 352 | lc := lru.NewLRU[string, string](0, nil, 0) |
| 353 | wg := sync.WaitGroup{} |
| 354 | wg.Add(1000) |
| 355 | for i := 0; i < 1000; i++ { |
| 356 | go func(i int) { |
| 357 | lc.Add(fmt.Sprintf("key-%d", i/10), fmt.Sprintf("val-%d", i/10)) |
| 358 | wg.Done() |
| 359 | }(i) |
| 360 | } |
| 361 | wg.Wait() |
| 362 | if lc.Len() != 100 { |
| 363 | t.Fatalf("length differs from expected") |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | func TestLRUInvalidateAndEvict(t *testing.T) { |
| 368 | var evicted int |