Skip to content

Commit 3f7fdc8

Browse files
committed
Add more LRU cache coverage
1 parent ed3eac9 commit 3f7fdc8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_lru_cache.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,26 @@ def test_cache_eviction():
3535
cache.set(4, 4)
3636
assert cache.get(3) is None
3737
assert cache.get(4) == 4
38+
39+
40+
def test_cache_miss():
41+
cache = LRUCache(1)
42+
assert cache.get(0) is None
43+
44+
45+
def test_cache_set_overwrite():
46+
cache = LRUCache(3)
47+
cache.set(0, 0)
48+
cache.set(0, 1)
49+
assert cache.get(0) == 1
50+
51+
52+
def test_cache_get_all():
53+
cache = LRUCache(3)
54+
cache.set(0, 0)
55+
cache.set(1, 1)
56+
cache.set(2, 2)
57+
cache.set(3, 3)
58+
assert cache.get_all() == [(1, 1), (2, 2), (3, 3)]
59+
cache.get(1)
60+
assert cache.get_all() == [(2, 2), (3, 3), (1, 1)]

0 commit comments

Comments
 (0)