()
| 9 | |
| 10 | |
| 11 | def test_simple() -> None: |
| 12 | cache: LRUCache[Any, Any] = LRUCache(maxsize=2) |
| 13 | cache["x"] = 1 |
| 14 | cache["y"] = 2 |
| 15 | |
| 16 | assert cache["x"] == 1 |
| 17 | assert cache["y"] == 2 |
| 18 | assert len(cache) == 2 |
| 19 | assert dict(cache) == {"x": 1, "y": 2} |
| 20 | assert list(cache.keys()) == ["x", "y"] |
| 21 | assert list(cache.items()) == [("x", 1), ("y", 2)] |
| 22 | |
| 23 | cache["z"] = 3 |
| 24 | assert len(cache) == 2 |
| 25 | assert list(cache.items()) == [("y", 2), ("z", 3)] |
| 26 | |
| 27 | |
| 28 | def test_trivial() -> None: |