diff options
author | hut <hut@lavabit.com> | 2009-12-05 16:53:12 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-05 16:53:12 +0100 |
commit | 22bb7e358ccd6efc58c38b8703b6818131905a75 (patch) | |
tree | a597a8c9302bbf19e08cf37dd2938264fad2c0f9 /test | |
parent | ffec67de733cfa2ee1c2dab6b87f933565180330 (diff) | |
download | ranger-22bb7e358ccd6efc58c38b8703b6818131905a75.tar.gz |
History Object + Test Case
Diffstat (limited to 'test')
-rw-r--r-- | test/tc_history.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/tc_history.py b/test/tc_history.py new file mode 100644 index 00000000..3e5adcff --- /dev/null +++ b/test/tc_history.py @@ -0,0 +1,44 @@ +if __name__ == '__main__': + from os.path import abspath, join + import sys + sys.path.append(abspath(join(sys.path[0], '..'))) + +from ranger.history import History +from unittest import TestCase, main +import unittest + +class Test(TestCase): + def test_everything(self): + hist = History(3) + for i in range(6): + hist.add(i) + self.assertEqual([3,4,5], list(hist)) + + hist.back() + + self.assertEqual(4, hist.top()) + self.assertEqual([3,4], list(hist)) + + hist.back() + self.assertEqual(3, hist.top()) + self.assertEqual([3], list(hist)) + + # no change if top == bottom + self.assertEqual(hist.top(), hist.bottom()) + last_top = hist.top() + hist.back() + self.assertEqual(hist.top(), last_top) + + + hist.forward() + hist.forward() + self.assertEqual(5, hist.top()) + self.assertEqual([3,4,5], list(hist)) + + + self.assertEqual(3, hist.bottom()) + hist.add(6) + self.assertEqual(4, hist.bottom()) + self.assertEqual([4,5,6], list(hist)) + +if __name__ == '__main__': main() |