summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-02-24 23:14:39 +1100
committerDamien George <damien.p.george@gmail.com>2018-02-24 23:14:39 +1100
commit77a62d8b5add1c6feea307a2b6c23552cdac05ce (patch)
treedbc6868ac999ed8cc59c25abb1879decd47e33f0
parent90da791a08bee6e4d9706dd80f9c15f22ff4c50f (diff)
tests/stress: Add test to create a dict beyond "maximum" rehash size.
There is a finite list of ascending primes used for the size of a hash table, and this test tests that the code can handle a dict larger than the maximum value in that list of primes. Adding this tests gets py/map.c to 100% coverage.
-rw-r--r--tests/stress/dict_create_max.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/stress/dict_create_max.py b/tests/stress/dict_create_max.py
new file mode 100644
index 000000000..3c75db20d
--- /dev/null
+++ b/tests/stress/dict_create_max.py
@@ -0,0 +1,13 @@
+# The aim with this test is to hit the maximum resize/rehash size of a dict,
+# where there are no more primes in the table of growing allocation sizes.
+# This value is 54907 items.
+
+d = {}
+try:
+ for i in range(54908):
+ d[i] = i
+except MemoryError:
+ pass
+
+# Just check the dict still has the first value
+print(d[0])