install.fairie/dotfiles/.vim/plugged/fzf/src/cache_test.go
Git E2E Dev Test Username 8c6fca48ea git subrepo clone https://github.com/junegunn/fzf.git ./dotfiles/.vim/plugged/fzf
subrepo:
  subdir:   "dotfiles/.vim/plugged/fzf"
  merged:   "dad26d81d"
upstream:
  origin:   "https://github.com/junegunn/fzf.git"
  branch:   "master"
  commit:   "dad26d81d"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
2022-10-18 10:37:14 -04:00

39 lines
859 B
Go

package fzf
import "testing"
func TestChunkCache(t *testing.T) {
cache := NewChunkCache()
chunk1p := &Chunk{}
chunk2p := &Chunk{count: chunkSize}
items1 := []Result{{}}
items2 := []Result{{}, {}}
cache.Add(chunk1p, "foo", items1)
cache.Add(chunk2p, "foo", items1)
cache.Add(chunk2p, "bar", items2)
{ // chunk1 is not full
cached := cache.Lookup(chunk1p, "foo")
if cached != nil {
t.Error("Cached disabled for non-empty chunks", cached)
}
}
{
cached := cache.Lookup(chunk2p, "foo")
if cached == nil || len(cached) != 1 {
t.Error("Expected 1 item cached", cached)
}
}
{
cached := cache.Lookup(chunk2p, "bar")
if cached == nil || len(cached) != 2 {
t.Error("Expected 2 items cached", cached)
}
}
{
cached := cache.Lookup(chunk1p, "foobar")
if cached != nil {
t.Error("Expected 0 item cached", cached)
}
}
}