Skip to content

Commit

Permalink
fix editor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenZcience committed Jan 21, 2024
1 parent cc31609 commit e080be0
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions cat_win/tests/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,190 +38,190 @@ def test_editor_key_enter(self):
editor = Editor(test_file_path_oneline, 'utf-8')
editor._key_enter(None)
self.assertListEqual(editor.window_content, ['', 'test'])
editor._key_right(None)
editor._move_key_right()
editor._key_enter(None)
self.assertListEqual(editor.window_content, ['', 't', 'est'])
editor._key_end(None)
editor._move_key_end()
editor._key_enter(None)
self.assertListEqual(editor.window_content, ['', 't', 'est', ''])

def test_editor_key_dc(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_dc(None)
self.assertListEqual(editor.window_content, ['ine 1', 'line 2'])
editor._key_right(None)
editor._move_key_right()
editor._key_dc(None)
self.assertListEqual(editor.window_content, ['ie 1', 'line 2'])
editor._key_end(None)
editor._move_key_end()
editor._key_dc(None)
self.assertListEqual(editor.window_content, ['ie 1line 2'])
editor._key_end(None)
editor._move_key_end()
editor._key_dc(None)
self.assertListEqual(editor.window_content, ['ie 1line 2'])

def test_editor_key_dl(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_dl(None)
self.assertListEqual(editor.window_content, [' 1', 'line 2'])
editor._key_right(None)
editor._move_key_right()
editor._key_dl(None)
self.assertListEqual(editor.window_content, [' ', 'line 2'])
editor._key_dl(None)
self.assertListEqual(editor.window_content, [' line 2'])
editor._key_end(None)
editor._move_key_end()
editor._key_dl(None)
self.assertListEqual(editor.window_content, [' line 2'])

def test_editor_key_backspace(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_backspace(None)
self.assertListEqual(editor.window_content, ['line 1', 'line 2'])
editor._key_ctl_end(None)
editor._move_key_ctl_end()
editor._key_backspace(None)
self.assertListEqual(editor.window_content, ['line 1', 'line '])
editor._key_left(None)
editor._move_key_left()
editor._key_backspace(None)
self.assertListEqual(editor.window_content, ['line 1', 'lin '])
editor._key_home(None)
editor._move_key_home()
editor._key_backspace(None)
self.assertListEqual(editor.window_content, ['line 1lin '])

def test_editor_key_ctl_backspace(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_ctl_backspace(None)
self.assertListEqual(editor.window_content, ['line 1', 'line 2'])
editor._key_ctl_end(None)
editor._move_key_ctl_end()
editor._key_ctl_backspace(None)
self.assertListEqual(editor.window_content, ['line 1', 'line'])
editor._key_home(None)
editor._key_right(None)
editor._move_key_home()
editor._move_key_right()
editor._key_ctl_backspace(None)
self.assertListEqual(editor.window_content, ['line 1', 'ine'])
editor._key_ctl_backspace(None)
self.assertListEqual(editor.window_content, ['line 1ine'])

def test_editor_key_left(self):
def test_editor_move_key_left(self):
editor = Editor(test_file_path_editor, 'utf-8')
self.assertEqual(editor._key_left(None), None)
self.assertEqual(editor._move_key_left(), None)
self.assertEqual(editor.cpos.get_pos(), (0,0))
editor.cpos.set_pos((1,0))
editor._key_left(None)
editor._move_key_left()
self.assertEqual(editor.cpos.get_pos(), (0,6))
editor._key_left(None)
editor._move_key_left()
self.assertEqual(editor.cpos.get_pos(), (0,5))

def test_editor_key_right(self):
def test_editor_move_key_right(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor.cpos.set_pos((1,6))
self.assertEqual(editor._key_right(None), None)
self.assertEqual(editor._move_key_right(), None)
self.assertEqual(editor.cpos.get_pos(), (1,6))
editor.cpos.set_pos((0,6))
editor._key_right(None)
editor._move_key_right()
self.assertEqual(editor.cpos.get_pos(), (1,0))
editor._key_right(None)
editor._move_key_right()
self.assertEqual(editor.cpos.get_pos(), (1,1))

def test_editor_key_up(self):
def test_editor_move_key_up(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor.cpos.set_pos((1,3))
editor._key_up(None)
editor._move_key_up()
self.assertEqual(editor.cpos.get_pos(), (0,3))
self.assertEqual(editor._key_up(None), None)
self.assertEqual(editor._move_key_up(), None)
self.assertEqual(editor.cpos.get_pos(), (0,3))

def test_editor_key_down(self):
def test_editor_move_key_down(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_down(None)
editor._move_key_down()
self.assertEqual(editor.cpos.get_pos(), (1,0))
self.assertEqual(editor._key_down(None), None)
self.assertEqual(editor._move_key_down(), None)
self.assertEqual(editor.cpos.get_pos(), (1,0))

def test_editor_key_ctl_left(self):
def test_editor_move_key_ctl_left(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_ctl_left(None)
editor._move_key_ctl_left()
self.assertEqual(editor.cpos.get_pos(), (0,0))
editor.cpos.set_pos((1,6))
editor._key_ctl_left(None)
editor._move_key_ctl_left()
self.assertEqual(editor.cpos.get_pos(), (1,4))
editor._key_ctl_left(None)
editor._move_key_ctl_left()
self.assertEqual(editor.cpos.get_pos(), (1,0))
editor.cpos.set_pos((1,1))
editor._key_ctl_left(None)
editor._move_key_ctl_left()
self.assertEqual(editor.cpos.get_pos(), (1,0))
editor._key_ctl_left(None)
editor._move_key_ctl_left()
self.assertEqual(editor.cpos.get_pos(), (0,6))

def test_editor_key_ctl_right(self):
def test_editor_move_key_ctl_right(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_ctl_right(None)
editor._move_key_ctl_right()
self.assertEqual(editor.cpos.get_pos(), (0,4))
editor._key_ctl_right(None)
editor._move_key_ctl_right()
self.assertEqual(editor.cpos.get_pos(), (0,6))
editor.cpos.set_pos((0,5))
editor._key_ctl_right(None)
editor._move_key_ctl_right()
self.assertEqual(editor.cpos.get_pos(), (0,6))
editor._key_ctl_right(None)
editor._move_key_ctl_right()
self.assertEqual(editor.cpos.get_pos(), (1,0))
editor.cpos.set_pos((1,6))
editor._key_ctl_right(None)
editor._move_key_ctl_right()
self.assertEqual(editor.cpos.get_pos(), (1,6))

def test_editor_key_ctl_up(self):
def test_editor_move_key_ctl_up(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_ctl_up(None)
editor._move_key_ctl_up()
self.assertEqual(editor.cpos.get_pos(), (0,0))
editor.cpos.set_pos((1,6))
editor._key_ctl_up(None)
editor._move_key_ctl_up()
self.assertEqual(editor.cpos.get_pos(), (0,0))
editor.cpos.set_pos((11,4))
editor._key_ctl_up(None)
editor._move_key_ctl_up()
self.assertEqual(editor.cpos.get_pos(), (1,4))

def test_editor_key_ctl_down(self):
def test_editor_move_key_ctl_down(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_ctl_down(None)
editor._move_key_ctl_down()
self.assertEqual(editor.cpos.get_pos(), (1,6))
editor._key_ctl_down(None)
editor._move_key_ctl_down()
self.assertEqual(editor.cpos.get_pos(), (1,6))
editor.cpos.set_pos((-9, 3))
editor._key_ctl_down(None)
editor._move_key_ctl_down()
self.assertEqual(editor.cpos.get_pos(), (1,3))

def test_editor_key_end(self):
def test_editor_move_key_end(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_end(None)
editor._move_key_end()
self.assertEqual(editor.cpos.get_pos(), (0,6))
editor._key_end(None)
editor._move_key_end()
self.assertEqual(editor.cpos.get_pos(), (0,6))

def test_editor_key_ctl_end(self):
def test_editor_move_key_ctl_end(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_ctl_end(None)
editor._move_key_ctl_end()
self.assertEqual(editor.cpos.get_pos(), (1,6))
editor._key_ctl_end(None)
editor._move_key_ctl_end()
self.assertEqual(editor.cpos.get_pos(), (1,6))

def test_editor_key_home(self):
def test_editor_move_key_home(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_home(None)
editor._move_key_home()
self.assertEqual(editor.cpos.get_pos(), (0,0))
editor.cpos.set_pos((1,3))
editor._key_home(None)
editor._move_key_home()
self.assertEqual(editor.cpos.get_pos(), (1,0))

def test_editor_key_ctl_home(self):
def test_editor_move_key_ctl_home(self):
editor = Editor(test_file_path_editor, 'utf-8')
editor._key_ctl_home(None)
editor._move_key_ctl_home()
self.assertEqual(editor.cpos.get_pos(), (0,0))
editor.cpos.set_pos((1,3))
editor._key_ctl_home(None)
editor._move_key_ctl_home()
self.assertEqual(editor.cpos.get_pos(), (0,0))

def test_editor_key_string(self):
editor = Editor(test_file_path_editor, 'utf-8')
self.assertEqual(editor._key_string(1), '')
self.assertListEqual(editor.window_content, ['line 1', 'line 2'])
editor._key_right(None)
editor._move_key_right()
editor._key_string('test')
self.assertListEqual(editor.window_content, ['ltestine 1', 'line 2'])

Expand Down

0 comments on commit e080be0

Please sign in to comment.