Skip to content
Myr

cache_test.go

This file

Path

src/cache_test.go

40 lines · 917 bytes · Go

Last changed by

Micro-optimizationsJunegunn Choibefore adoption37dc273

History of this file

Take it

The walk stopped after 200 commits: lines older than 7bcf4ef point at it.

Fix test failure - use absolute pathJunegunn Choibefore adoption7bcf4ef

lines 1–9why, one step back
1package fzf
23import "testing"45func TestChunkCache(t *testing.T) {6 cache := NewChunkCache()7 chunk2 := make(Chunk, chunkSize)8 chunk1p := &Chunk{}9 chunk2p := &chunk2

Micro-optimizationsJunegunn Choibefore adoption37dc273

lines 10–11why, one step back
10 items1 := []*Result{&Result{}}
11 items2 := []*Result{&Result{}, &Result{}}

Fix test failure - use absolute pathJunegunn Choibefore adoption7bcf4ef

lines 12–40why, one step back
12 cache.Add(chunk1p, "foo", items1)
13 cache.Add(chunk2p, "foo", items1)14 cache.Add(chunk2p, "bar", items2)1516 { // chunk1 is not full17 cached, found := cache.Find(chunk1p, "foo")18 if found {19 t.Error("Cached disabled for non-empty chunks", found, cached)20 }21 }22 {23 cached, found := cache.Find(chunk2p, "foo")24 if !found || len(cached) != 1 {25 t.Error("Expected 1 item cached", found, cached)26 }27 }28 {29 cached, found := cache.Find(chunk2p, "bar")30 if !found || len(cached) != 2 {31 t.Error("Expected 2 items cached", found, cached)32 }33 }34 {35 cached, found := cache.Find(chunk1p, "foobar")36 if found {37 t.Error("Expected 0 item cached", found, cached)38 }39 }40}