aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuri Takhteyev <yuri@freewisdom.org>2008-10-13 00:42:08 -0700
committerYuri Takhteyev <yuri@freewisdom.org>2008-10-13 00:42:08 -0700
commit8a67923cbc704e45434905d34abad54ada97ab20 (patch)
tree3daac55f1cd7cd4c2dec5073ae64e985aaed885c
parent7741fe10831c5986866ce584211012d8fccbcd3f (diff)
downloadmarkdown-8a67923cbc704e45434905d34abad54ada97ab20.tar.gz
markdown-8a67923cbc704e45434905d34abad54ada97ab20.tar.bz2
markdown-8a67923cbc704e45434905d34abad54ada97ab20.zip
Checking in treap_test.py in lieu of documentation.
-rw-r--r--treap_test.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/treap_test.py b/treap_test.py
new file mode 100644
index 0000000..a1e2183
--- /dev/null
+++ b/treap_test.py
@@ -0,0 +1,50 @@
+from markdown import Treap
+
+if __name__ == '__main__':
+ from pprint import pprint
+
+ def test(t, b):
+ if b is True:
+ print t, "Passed"
+ else:
+ print t, "Failed"
+
+ print "Testing..."
+ r = Treap()
+ r.add('first', 'This', '_begin')
+ r.add('second', 'is', '>first')
+ r.add('fourth', 'self', '>second')
+ r.add('fifth', 'test', '>fourth')
+ r.add('third', 'a', '>second')
+ r['seventh'] = '.'
+
+ print ".. Heapsort Test"
+ test('.... vals', r.heapsorted() == ['This', 'is', 'a', 'self', 'test','.'])
+ test('.... keys', r.heapsorted(keys=1) == ['first', 'second', 'third', 'fourth', 'fifth','seventh'])
+ test('.... items', r.heapsorted(items=1) == [('first', 'This'), ('second', 'is'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test'), ('seventh','.')])
+
+ print ".. Dict Storage Test"
+ r._reset()
+ test('.... vals', r.values() == r._vals)
+ r._reset()
+ test('.... keys', r.keys() == r._keys)
+ r._reset()
+ test('.... items', r.items() == r._items)
+
+ print ".. Delete Node Test"
+ del r['second']
+ test('.... vals', r.heapsorted() == ['This', 'a', 'self', 'test','.'])
+ test('.... keys', r.heapsorted(keys=1) == ['first', 'third', 'fourth', 'fifth','seventh'])
+ test('.... items', r.heapsorted(items=1) == [('first', 'This'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test'), ('seventh','.')])
+
+ print ".. Change value test."
+ r['seventh'] = 'CRAZY'
+ test('.... vals', r.heapsorted() == ['This', 'a', 'self', 'test','CRAZY'])
+ test('.... keys', r.heapsorted(keys=1) == ['first', 'third', 'fourth', 'fifth','seventh'])
+ test('.... items', r.heapsorted(items=1) == [('first', 'This'), ('third', 'a'), ('fourth', 'self'), ('fifth', 'test'), ('seventh','CRAZY')])
+ print ".. Change priority test."
+ r.link('seventh', '<third')
+ test('.... vals', r.heapsorted() == ['This', 'a', 'self', 'CRAZY', 'test'])
+ test('.... keys', r.heapsorted(keys=1) == ['first', 'third', 'fourth','seventh', 'fifth'])
+ test('.... items', r.heapsorted(items=1) == [('first', 'This'), ('third', 'a'), ('fourth', 'self'), ('seventh','CRAZY'), ('fifth', 'test')])
+