diff options
author | Jay Hutchinson <jlhutch@gmail.com> | 2011-07-25 13:18:45 -0500 |
---|---|---|
committer | Jay Hutchinson <jlhutch@gmail.com> | 2011-07-25 13:18:45 -0500 |
commit | 578c0ac4cbc434d89554312f28153ae109fd1d96 (patch) | |
tree | a511722eb718f231694c44400125fe9a451c1d85 | |
parent | dc9d12ac9a95e653c72132dd0ddde28b6e72cedd (diff) | |
download | pylru-578c0ac4cbc434d89554312f28153ae109fd1d96.tar.gz |
Added code to test resizing a cache.
-rw-r--r-- | test.py | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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) |