From e573579b2f76c43b775dba47d4caed6c8b280299 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz <welzwo@gmail.com> Date: Wed, 12 Jun 2019 11:12:27 +0200 Subject: [PATCH] Fix compute if absent test for lru --- packages/datastructure/lru_cache_test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/datastructure/lru_cache_test.go b/packages/datastructure/lru_cache_test.go index ac5dbd74..5d314374 100644 --- a/packages/datastructure/lru_cache_test.go +++ b/packages/datastructure/lru_cache_test.go @@ -56,9 +56,16 @@ func TestLRUCache(t *testing.T) { t.Error("'b' should have been dropped") } - cache.ComputeIfAbsent("tust", func() interface{} { - return 1337 - }) + { + key, value := "test2", 1337 + + cache.ComputeIfAbsent(key, func() interface{} { + return value + }) + if cache.Get(key) != value { + t.Error("'" + key + "' should have been added") + } + } if cache.GetSize() != 5 { t.Error("the size should be 5") -- GitLab