Spaces:
Running on Zero
Running on Zero
File size: 388 Bytes
36333c5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | """Bounded cache behavior."""
from core.cache import LRUCache
def test_lru_cache_promotes_reads_before_eviction() -> None:
cache: LRUCache[str, int] = LRUCache(capacity=2)
assert cache.put("a", 1) is None
assert cache.put("b", 2) is None
assert cache.get("a") == 1
assert cache.put("c", 3) == ("b", 2)
assert cache.get("a") == 1
assert cache.get("c") == 3
|