summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/tc_history.py44
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()
t { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
package lexical

import (
	"sort"
	"strings"
)

// SlowSort returns string in lexical order. This function is slower
// than Lexical.
func SlowSort(word string) (sorted string) {
	// Convert word to a slice, sort the slice.
	t := strings.Split(word, "")
	sort.Strings(t)

	sorted = strings.Join(t, "")
	return
}