Coverage for core\test_leoVim.py: 100%

33 statements  

« prev     ^ index     » next       coverage.py v6.4, created at 2022-05-24 10:21 -0500

1# -*- coding: utf-8 -*- 

2#@+leo-ver=5-thin 

3#@+node:ekr.20210910072917.1: * @file ../unittests/core/test_leoVim.py 

4#@@first 

5"""Tests of leoVim.py""" 

6 

7import textwrap 

8from leo.core import leoGlobals as g 

9from leo.core.leoTest2 import LeoUnitTest 

10assert g 

11 

12#@+others 

13#@+node:ekr.20210910072917.2: ** class TestVim (LeoUnitTest) 

14class TestVim(LeoUnitTest): 

15 #@+others 

16 #@+node:ekr.20210909194336.58: *3* TestVim.test_vc_on_same_line 

17 def test_vc_on_same_line(self): 

18 c = self.c 

19 vc = c.vimCommands 

20 s = textwrap.dedent(""" 

21 abc 

22 xyz 

23 pdq 

24 """) 

25 table = ( 

26 ('ab', 'y', False), 

27 ('a', 'c', True), 

28 ('x', '\np', True), 

29 ('\nx', 'z', False), 

30 ) 

31 for a, b, expected in table: 

32 i1, i2 = s.find(a), s.find(b) 

33 result = vc.on_same_line(s, i1, i2) 

34 self.assertEqual(result, expected, msg=s[i1:i2]) 

35 #@+node:ekr.20210909194336.59: *3* TestVim.test_vc_to_bol 

36 def test_vc_to_bol(self): 

37 c = self.c 

38 vc = c.vimCommands 

39 s = textwrap.dedent(""" 

40 abc 

41 xyz 

42 """) 

43 table = ( 

44 ('a', 'a'), 

45 ('a', 'b'), 

46 ('a', '\nx') 

47 ) 

48 for a, b, in table: 

49 i1, i2 = s.find(a), s.find(b) 

50 result = vc.to_bol(s, i2) 

51 self.assertEqual(result, i1, msg=s[i1:i2]) 

52 #@+node:ekr.20210909194336.60: *3* TestVim.test_vc_to_eol 

53 def test_vc_to_eol(self): 

54 c = self.c 

55 vc = c.vimCommands 

56 s = textwrap.dedent(""" 

57 abc 

58 xyz 

59 """) 

60 table = ( 

61 ('a', '\nx'), 

62 ('b', '\nx'), 

63 ('c', '\nx'), 

64 ('\nx', '\nx'), 

65 ) 

66 for a, b, in table: 

67 i1, i2 = s.find(a), s.find(b) 

68 result = vc.to_eol(s, i1) 

69 self.assertEqual(result, i2, msg=s[i1:i2]) 

70 #@-others 

71#@-others 

72#@-leo