diff options
author | Marc Pervaz Boocha <marcpervaz@qburst.com> | 2025-02-21 18:24:35 +0530 |
---|---|---|
committer | Marc Pervaz Boocha <marcpervaz@qburst.com> | 2025-02-21 18:24:35 +0530 |
commit | a470aa89cbdabba813636b8a29be8ae3836c03a0 (patch) | |
tree | 2551bebaff980cc93bf8fcf60dd8ff50bd7efc48 /map_test.go | |
parent | Add Tests and benchmarks (diff) | |
download | cache-a470aa89cbdabba813636b8a29be8ae3836c03a0.tar cache-a470aa89cbdabba813636b8a29be8ae3836c03a0.tar.gz cache-a470aa89cbdabba813636b8a29be8ae3836c03a0.tar.bz2 cache-a470aa89cbdabba813636b8a29be8ae3836c03a0.tar.lz cache-a470aa89cbdabba813636b8a29be8ae3836c03a0.tar.xz cache-a470aa89cbdabba813636b8a29be8ae3836c03a0.tar.zst cache-a470aa89cbdabba813636b8a29be8ae3836c03a0.zip |
Added LTR Eviction
Diffstat (limited to 'map_test.go')
-rw-r--r-- | map_test.go | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/map_test.go b/map_test.go deleted file mode 100644 index 5610d0a..0000000 --- a/map_test.go +++ /dev/null @@ -1,114 +0,0 @@ -package cache - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func setupTestStore(t testing.TB) *store { - t.Helper() - - store := &store{} - store.Init() - return store -} - -func TestStoreGetSet(t *testing.T) { - t.Parallel() - - t.Run("Exists", func(t *testing.T) { - t.Parallel() - - store := setupTestStore(t) - - want := []byte("Value") - store.Set([]byte("Key"), want, 0) - got, _, ok := store.Get([]byte("Key")) - assert.Equal(t, want, got) - assert.True(t, ok) - }) - - t.Run("Not Exists", func(t *testing.T) { - t.Parallel() - - store := setupTestStore(t) - - _, _, ok := store.Get([]byte("Key")) - assert.False(t, ok) - }) - - t.Run("Update", func(t *testing.T) { - t.Parallel() - - store := setupTestStore(t) - - store.Set([]byte("Key"), []byte("Other"), 0) - want := []byte("Value") - store.Set([]byte("Key"), want, 0) - got, _, ok := store.Get([]byte("Key")) - assert.Equal(t, want, got) - assert.True(t, ok) - }) -} - -func TestStoreDelete(t *testing.T) { - t.Parallel() - - t.Run("Exists", func(t *testing.T) { - t.Parallel() - - store := setupTestStore(t) - - want := []byte("Value") - store.Set([]byte("Key"), want, 0) - ok := store.Delete([]byte("Key")) - assert.True(t, ok) - _, _, ok = store.Get([]byte("Key")) - assert.False(t, ok) - }) - - t.Run("Not Exists", func(t *testing.T) { - t.Parallel() - - store := setupTestStore(t) - - ok := store.Delete([]byte("Key")) - assert.False(t, ok) - }) -} - -func TestStoreClear(t *testing.T) { - t.Parallel() - - store := setupTestStore(t) - - want := []byte("Value") - store.Set([]byte("Key"), want, 0) - store.Clear() - _, _, ok := store.Get([]byte("Key")) - assert.False(t, ok) -} - -func BenchmarkStoreGet(b *testing.B) { - store := setupTestStore(b) - - key := []byte("Key") - store.Set(key, []byte("Store"), 0) - b.ReportAllocs() - - for i := 0; i < b.N; i++ { - store.Get(key) - } -} - -func BenchmarkStoreSet(b *testing.B) { - store := setupTestStore(b) - - key := []byte("Key") - b.ReportAllocs() - - for i := 0; i < b.N; i++ { - store.Set(key, []byte("Store"), 0) - } -} |