Sha256: 474e8557492d4b371b74b9bfdd4c325161462d59d16bdfc4978081b71ad72741

Contents?: true

Size: 859 Bytes

Versions: 87

Compression:

Stored size: 859 Bytes

Contents

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)
		}
	}
}

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
doing-2.1.88 lib/helpers/fzf/src/cache_test.go
doing-2.1.87 lib/helpers/fzf/src/cache_test.go
doing-2.1.86 lib/helpers/fzf/src/cache_test.go
doing-2.1.85 lib/helpers/fzf/src/cache_test.go
doing-2.1.84 lib/helpers/fzf/src/cache_test.go
doing-2.1.83 lib/helpers/fzf/src/cache_test.go
doing-2.1.82 lib/helpers/fzf/src/cache_test.go
doing-2.1.81 lib/helpers/fzf/src/cache_test.go
doing-2.1.80 lib/helpers/fzf/src/cache_test.go
doing-2.1.79 lib/helpers/fzf/src/cache_test.go
doing-2.1.78 lib/helpers/fzf/src/cache_test.go
doing-2.1.77 lib/helpers/fzf/src/cache_test.go
doing-2.1.76 lib/helpers/fzf/src/cache_test.go
doing-2.1.75 lib/helpers/fzf/src/cache_test.go
doing-2.1.74 lib/helpers/fzf/src/cache_test.go
doing-2.1.73 lib/helpers/fzf/src/cache_test.go
doing-2.1.72 lib/helpers/fzf/src/cache_test.go
doing-2.1.69 lib/helpers/fzf/src/cache_test.go
doing-2.1.68 lib/helpers/fzf/src/cache_test.go
doing-2.1.66 lib/helpers/fzf/src/cache_test.go