|
|
@@ -21,3 +21,28 @@ class TestRBTree: |
|
|
|
# There was a typo that gave the RBTree a loop in this case. |
|
|
|
# Verify that the dot isn't too big. |
|
|
|
assert(len(s.splitlines()) < 30) |
|
|
|
|
|
|
|
#@unittest.skip("needs GTK") |
|
|
|
def test_rbtree_big(self): |
|
|
|
import random |
|
|
|
random.seed(1234) |
|
|
|
# make a set of 500 intervals |
|
|
|
rb = RBTree() |
|
|
|
j = 500 |
|
|
|
for i in random.sample(xrange(j),j): |
|
|
|
print "inserting", i |
|
|
|
rb.insert(RBNode(None, i, i+1)) |
|
|
|
|
|
|
|
# show the graph |
|
|
|
rb.render_dot_live("after insert") |
|
|
|
|
|
|
|
# remove about half of them |
|
|
|
for i in random.sample(xrange(j),j): |
|
|
|
if random.randint(0,1): |
|
|
|
print "deleting", i |
|
|
|
if i == 300: |
|
|
|
rb.render_dot_live("before deleting 300") |
|
|
|
rb.delete(rb.find(i, i+1)) |
|
|
|
|
|
|
|
# show the graph |
|
|
|
rb.render_dot_live("after delete") |