Skip to content

Commit

Permalink
add tests for case folding
Browse files Browse the repository at this point in the history
  • Loading branch information
lotabout committed Feb 23, 2020
1 parent 9824343 commit 3edc75d
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions test/test_skim.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,86 @@ def test_ansi_and_read0(self):
output = ":".join("{:02x}".format(ord(c)) for c in self.readonce())
self.assertTrue(output.find("61:00:62:0a") >= 0)

def test_smart_case_fuzzy(self):
"""should behave correctly on case, #219"""

# smart case
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('abc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Ctrl('u'), Key('aBc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Ctrl('u'), Key('ABc'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('Enter'))
self.assertEqual('', self.readonce().strip())

def test_smart_case_exact(self):
"""should behave correctly on case, #219"""

# smart case
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key("'abc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Ctrl('u'), Key("'aBc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Ctrl('u'), Key("'ABc"))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('Enter'))
self.assertEqual('', self.readonce().strip())

def test_ignore_case_fuzzy(self):
"""should behave correctly on case, #219"""

# ignore case
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('--case ignore')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('abc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Ctrl('u'), Key('aBc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Ctrl('u'), Key('ABc'))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Key('Enter'))

def test_ignore_case_exact(self):
"""should behave correctly on case, #219"""

# ignore case
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('--case ignore')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key("'abc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Ctrl('u'), Key("'aBc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Ctrl('u'), Key("'ABc"))
self.tmux.until(lambda lines: lines[-3].startswith('> aBcXyZ'))
self.tmux.send_keys(Key('Enter'))

def test_respect_case_fuzzy(self):
"""should behave correctly on case, #219"""

# respect case
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('--case respect')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('abc'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('Enter'))
self.assertEqual('', self.readonce().strip())

def test_respect_case_exact(self):
"""should behave correctly on case, #219"""

# respect case
self.tmux.send_keys(f"echo -e 'aBcXyZ' | {self.sk('--case respect')}", Key('Enter'))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key("'abc"))
self.tmux.until(lambda lines: lines.ready_with_lines(1))
self.tmux.send_keys(Key('Enter'))
self.assertEqual('', self.readonce().strip())

def find_prompt(lines, interactive=False, reverse=False):
linen = -1
prompt = ">"
Expand Down

0 comments on commit 3edc75d

Please sign in to comment.