(t *testing.T)
| 608 | } |
| 609 | |
| 610 | func TestAverageAccessTimeWhenUpdateWithNewSpace(t *testing.T) { |
| 611 | cache := NewCache(1024) |
| 612 | |
| 613 | key := []byte("test-key") |
| 614 | valueLong := []byte("very-long-de-value") |
| 615 | valueShort := []byte("short") |
| 616 | |
| 617 | err := cache.Set(key, valueShort, 0) |
| 618 | if err != nil { |
| 619 | t.Fatal("err should be nil") |
| 620 | } |
| 621 | now := time.Now().Unix() |
| 622 | aat := cache.AverageAccessTime() |
| 623 | if (now - aat) > 1 { |
| 624 | t.Fatalf("track average access time error, now:%d, aat:%d", now, aat) |
| 625 | } |
| 626 | |
| 627 | time.Sleep(time.Second * 4) |
| 628 | err = cache.Set(key, valueLong, 0) |
| 629 | if err != nil { |
| 630 | t.Fatal("err should be nil") |
| 631 | } |
| 632 | now = time.Now().Unix() |
| 633 | aat = cache.AverageAccessTime() |
| 634 | if (now - aat) > 2 { |
| 635 | t.Fatalf("track average access time error, now:%d, aat:%d", now, aat) |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | func TestLargeEntry(t *testing.T) { |
| 640 | cacheSize := 512 * 1024 |
nothing calls this directly
no test coverage detected
searching dependent graphs…