summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Hutchinson <jlhutch@gmail.com>2011-07-25 13:18:45 -0500
committerJay Hutchinson <jlhutch@gmail.com>2011-07-25 13:18:45 -0500
commit578c0ac4cbc434d89554312f28153ae109fd1d96 (patch)
treea511722eb718f231694c44400125fe9a451c1d85
parentdc9d12ac9a95e653c72132dd0ddde28b6e72cedd (diff)
downloadpylru-578c0ac4cbc434d89554312f28153ae109fd1d96.tar.gz
Added code to test resizing a cache.
-rw-r--r--test.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test.py b/test.py
index 258bf3f..c3346e3 100644
--- a/test.py
+++ b/test.py
@@ -59,6 +59,12 @@ class simplelrucache:
raise KeyError
+ def resize(self, x=None):
+ assert x > 0
+ self.size = x
+ if x < len(self.cache):
+ del self.cache[:len(self.cache) - x]
+
def test(a, b, c, d, verify):
@@ -112,7 +118,22 @@ def testcache():
a = lrucache(128)
b = simplelrucache(128)
+ verify(a, b)
+ test(a, b, a, b, verify)
+
+ a.size(71)
+ b.resize(71)
+ verify(a, b)
+ test(a, b, a, b, verify)
+
+ a.size(341)
+ b.resize(341)
+ verify(a, b)
+ test(a, b, a, b, verify)
+ a.size(127)
+ b.resize(127)
+ verify(a, b)
test(a, b, a, b, verify)