about summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
...
| * Add builds.sr.ht CI for OpenBSDWilliam Wennerström2020-02-176-23/+105
* | omemo: switch to 12 byte IVMichael Vetter2020-02-171-1/+1
* | Refactor win_print_history()Michael Vetter2020-02-174-14/+6
* | Refactor win_print_outgoing_muc_msg()Michael Vetter2020-02-173-15/+7
* | Refactor win_println_incoming_muc_msg()Michael Vetter2020-02-173-15/+7
* | Refactor win_print_outgoing()Michael Vetter2020-02-174-19/+10
* | Fix typoMichael Vetter2020-02-171-1/+1
* | Merge branch 'feature/sendfile-enc-warn'Michael Vetter2020-02-177-7/+157
|\ \ | |/ |/|
| * Mention how to enable unencrypted file transerMichael Vetter2020-02-171-2/+2
| * Make /sendfile in PGP session configurableMichael Vetter2020-02-176-3/+33
| * Make /sendfile in OTR session configurableMichael Vetter2020-02-177-6/+47
| * Make /sendfile in OMEMO session configurableMichael Vetter2020-02-177-10/+54
| * Disallow sendfile in e2ee chat sessionsmoppman2020-02-171-0/+35
|/
* test: Init window.layout to make compiler happyMichael Vetter2020-02-141-0/+1
* Add workaround for compiler warningMichael Vetter2020-02-141-1/+1
* xep-0308: Add note about tab completionMichael Vetter2020-02-141-1/+2
* xep-0308: add note about where corrections are possibleMichael Vetter2020-02-141-1/+2
* xep-0308: only allow /correct when corrections are enabledMichael Vetter2020-02-141-0/+5
* Merge pull request #1267 from profanity-im/feature/xep-0308-lmcMichael Vetter2020-02-1434-154/+594
|\
| * xep-0308: add caution noteMichael Vetter2020-02-141-1/+1
| * Rename buffer->from to buffer->display_fromMichael Vetter2020-02-143-10/+12
| * xep-0308: enable for carbon copied messagesMichael Vetter2020-02-142-1/+15
| * xep-0308: enable correction in outgoing messages with delivery receiptsMichael Vetter2020-02-143-8/+10
| * Always send delivery receipts if enabledMichael Vetter2020-02-141-14/+1
| * Rename win_print_with_receipt() -> win_print_outgoing_with_receipt()Michael Vetter2020-02-143-4/+4
| * Add myself to copyrightMichael Vetter2020-02-144-0/+4
| * Rename `win_println_them_message()` -> `win_println_incoming_muc_msg()`Michael Vetter2020-02-143-3/+3
| * Fix testsMichael Vetter2020-02-142-8/+8
| * xep-0308: remove replace_id from privwin signatureMichael Vetter2020-02-143-4/+4
| * xep-0308: adapt unit test stubsMichael Vetter2020-02-142-8/+6
| * xep-0308: only replace messages if the user enabled the featureMichael Vetter2020-02-141-3/+3
| * xep-0308: Make /correct work without quotation marksMichael Vetter2020-02-144-11/+14
| * xep-0308: Fix sending corrections for multiple wordsMichael Vetter2020-02-143-4/+7
| * xep-0308: Add autocompletion of last message for /correctMichael Vetter2020-02-141-4/+29
| * xep-0308: Implement LMC for outgoing MUC messagesMichael Vetter2020-02-1410-17/+71
| * Rename MUC PM handlerMichael Vetter2020-02-141-3/+3
| * xep-0308: Dont allow to correct MUC PMsMichael Vetter2020-02-143-10/+0
| * xep-0308: correct incoming MUC PMsMichael Vetter2020-02-121-0/+14
| * xep-0308: Display corrected incoming MUC messages correctlyMichael Vetter2020-02-124-5/+21
| * xep-0308: Don't check whether receiving clients supports this featureMichael Vetter2020-02-121-16/+1
| * xep-0308: enable corrections for outgoing encrypted messagesMichael Vetter2020-02-128-44/+55
| * Distinguish between _win_print() and _win_printf()Michael Vetter2020-02-121-19/+17
| * Rename win_correct_incoming to win_correctMichael Vetter2020-02-121-4/+4
| * xep-0308: update the UI upon sending a corrected messageMichael Vetter2020-02-118-24/+37
| * xep-0308: Implement `/correct` to correct the last send messageMichael Vetter2020-02-1013-11/+132
| * xep-0308: add cons_correction_setting stub to testsMichael Vetter2020-02-101-0/+1
| * xep-0308: make correction.char themeableMichael Vetter2020-02-103-0/+10
| * xep-0308: create setting to toggle lmcMichael Vetter2020-02-107-11/+27
| * xep-0308: set correction char in configMichael Vetter2020-02-105-1/+58
| * xep-0308: add `correction` autocompletionMichael Vetter2020-02-104-0/+48
class="highlight">
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

if __name__ == '__main__': from __init__ import init; init()

from ranger.container import History
from unittest import TestCase, main
import unittest

class Test(TestCase):
	def test_history(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.current())
		self.assertEqual([3,4], list(hist))

		self.assertEqual(5, hist.top())

		hist.back()
		self.assertEqual(3, hist.current())
		self.assertEqual([3], list(hist))

		# no change if current == bottom
		self.assertEqual(hist.current(), hist.bottom())
		last = hist.current()
		hist.back()
		self.assertEqual(hist.current(), last)

		self.assertEqual(5, hist.top())

		hist.forward()
		hist.forward()
		self.assertEqual(5, hist.current())
		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()