(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestSetIfAbsent(t *testing.T) { |
| 73 | cache := NewLRUCache(100) |
| 74 | data := &CacheValue{0} |
| 75 | key := "key" |
| 76 | cache.SetIfAbsent(key, data) |
| 77 | |
| 78 | v, ok := cache.Get(key) |
| 79 | if !ok || v.(*CacheValue) != data { |
| 80 | t.Errorf("Cache has incorrect value: %v != %v", data, v) |
| 81 | } |
| 82 | |
| 83 | cache.SetIfAbsent(key, &CacheValue{1}) |
| 84 | |
| 85 | v, ok = cache.Get(key) |
| 86 | if !ok || v.(*CacheValue) != data { |
| 87 | t.Errorf("Cache has incorrect value: %v != %v", data, v) |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | func TestGetValueWithMultipleTypes(t *testing.T) { |
| 92 | cache := NewLRUCache(100) |
nothing calls this directly
no test coverage detected