aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/tools/console/test_commander.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/mitmproxy/tools/console/test_commander.py b/test/mitmproxy/tools/console/test_commander.py
new file mode 100644
index 00000000..b1f23df4
--- /dev/null
+++ b/test/mitmproxy/tools/console/test_commander.py
@@ -0,0 +1,37 @@
+
+from mitmproxy.tools.console.commander import commander
+
+
+class TestCommandBuffer:
+
+ def test_backspace(self):
+ tests = [
+ [("", 0), ("", 0)],
+ [("1", 0), ("1", 0)],
+ [("1", 1), ("", 0)],
+ [("123", 3), ("12", 2)],
+ [("123", 2), ("13", 1)],
+ [("123", 0), ("123", 0)],
+ ]
+ for start, output in tests:
+ cb = commander.CommandBuffer()
+ cb.buf, cb.cursor = start[0], start[1]
+ cb.backspace()
+ assert cb.buf == output[0]
+ assert cb.cursor == output[1]
+
+ def test_insert(self):
+ tests = [
+ [("", 0), ("x", 1)],
+ [("a", 0), ("xa", 1)],
+ [("xa", 2), ("xax", 3)],
+ ]
+ for start, output in tests:
+ cb = commander.CommandBuffer()
+ cb.buf, cb.cursor = start[0], start[1]
+ cb.insert("x")
+ assert cb.buf == output[0]
+ assert cb.cursor == output[1]
+
+
+