mirror of
https://github.com/harivansh-afk/veet-code.git
synced 2026-04-15 11:02:21 +00:00
update testing frame and ui
This commit is contained in:
parent
fcb740f0c2
commit
205957c167
8 changed files with 173 additions and 101 deletions
|
|
@ -6,6 +6,24 @@ from solution import LRUCache
|
|||
class TestBasicCases:
|
||||
"""Test basic functionality with typical inputs."""
|
||||
|
||||
def test_example_one(self):
|
||||
"""Test first example from problem description."""
|
||||
cache = LRUCache(2)
|
||||
cache.put("a", 1)
|
||||
cache.put("b", 2)
|
||||
assert cache.get("a") == 1
|
||||
cache.put("c", 3)
|
||||
assert cache.get("b") == -1
|
||||
assert cache.get("c") == 3
|
||||
|
||||
def test_example_two(self):
|
||||
"""Test second example from problem description."""
|
||||
cache = LRUCache(1)
|
||||
cache.put("x", 10)
|
||||
cache.put("y", 20)
|
||||
assert cache.get("x") == -1
|
||||
assert cache.get("y") == 20
|
||||
|
||||
def test_basic_put_get(self):
|
||||
"""Test basic put and get operations."""
|
||||
cache = LRUCache(2)
|
||||
|
|
@ -14,24 +32,6 @@ class TestBasicCases:
|
|||
assert cache.get("a") == 1
|
||||
assert cache.get("b") == 2
|
||||
|
||||
def test_eviction_lru(self):
|
||||
"""Test that least recently used is evicted."""
|
||||
cache = LRUCache(2)
|
||||
cache.put("a", 1)
|
||||
cache.put("b", 2)
|
||||
cache.get("a") # a is now most recent
|
||||
cache.put("c", 3) # b should be evicted
|
||||
assert cache.get("b") == -1
|
||||
assert cache.get("a") == 1
|
||||
assert cache.get("c") == 3
|
||||
|
||||
def test_update_existing_key(self):
|
||||
"""Test updating an existing key."""
|
||||
cache = LRUCache(2)
|
||||
cache.put("a", 1)
|
||||
cache.put("a", 10)
|
||||
assert cache.get("a") == 10
|
||||
|
||||
|
||||
class TestEdgeCases:
|
||||
"""Test edge cases and boundary conditions."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue