summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test.py')
-rw-r--r--test.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/test.py b/test.py
index ca107f4..a6d0be3 100644
--- a/test.py
+++ b/test.py
@@ -158,7 +158,28 @@ def testDecorator():
assert square(x) == x*x
+def testItems():
+ a = lrucache(128)
+ b = simplelrucache(128)
+
+ for i in range(1000):
+ x = random.randint(0, 512)
+ y = random.randint(0, 512)
+ a[x] = y
+ b[x] = y
+
+ for k, v in a.items():
+ assert k in a
+ assert a[k] == v
+ assert b[k] == v
+
+ # ensure the order returned in items() is correct.
+ items = a.items()
+ for k, v in reversed(items):
+ a[k] = v
+ # test the order is returned correctly.
+ assert items == a.items()
if __name__ == '__main__':
@@ -172,5 +193,6 @@ if __name__ == '__main__':
wraptest2()
wraptest3()
testDecorator()
+ testItems()