From 3cc188952165ecc0a0bba81d36044b52ca8a279a Mon Sep 17 00:00:00 2001 From: knbr13 Date: Thu, 23 May 2024 01:39:28 +0300 Subject: [PATCH] add TestKeys_LRU --- lru_cache_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lru_cache_test.go b/lru_cache_test.go index 1d403b2..1a02830 100644 --- a/lru_cache_test.go +++ b/lru_cache_test.go @@ -139,6 +139,27 @@ func TestCopyTo_LRU(t *testing.T) { func TestKeys_LRU(t *testing.T) { c := NewLRU[string, string](10) + c.Set("key1", "value1") + c.Set("key2", "value2") + c.Set("key3", "value3") + c.Set("key4", "value4") + c.Set("key5", "value5") + c.SetWithTimeout("key6", "value6", 1) + c.SetWithTimeout("key7", "value7", 1) + c.SetWithTimeout("key8", "value8", 1) + c.SetWithTimeout("key9", "value9", 1) + c.Set("key10", "value10") + + keys := c.Keys() + + if len(keys) != 6 { + t.Errorf("Keys failed") + } +} + +func TestAllKeys_LRU(t *testing.T) { + c := NewLRU[string, string](10) + c.Set("key1", "value1") c.Set("key2", "value2") c.Set("key3", "value3")