-
Notifications
You must be signed in to change notification settings - Fork 4
/
fingers-tests.el
102 lines (83 loc) · 4.35 KB
/
fingers-tests.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
;;; fingers-tests.el --- Tests for fingers.el
;; Copyright (c) 2014 Felix Geller
;; Author: Felix Geller <fgeller@gmail.com>
;; Keywords: fingers modal editing workman
;; URL: http://github.com/fgeller/fingers.el
;; This file is not part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Tests for fingers.el
(require 'fingers)
(defun fingers-test-fingers-mark-inside-pair-strings (input position start end)
(with-temp-buffer
(insert input)
(goto-char position)
(fingers-mark-inside-pair-strings start end)
(fingers-copy-current-region 'kill)
(buffer-substring (point-min) (point-max))))
(defun fingers-test-fingers-mark-with-pair-strings (input position start end)
(with-temp-buffer
(insert input)
(goto-char position)
(fingers-mark-with-pair-strings start end)
(fingers-copy-current-region 'kill)
(buffer-substring (point-min) (point-max))))
(defun fingers-test-fingers-mark-with-pair-strings-and-whitespace (input position start end)
(with-temp-buffer
(insert input)
(goto-char position)
(fingers-mark-with-pair-strings-and-whitespace start end)
(fingers-copy-current-region 'kill)
(buffer-substring (point-min) (point-max))))
(ert-deftest fingers-test:fingers-mark-inside-pair ()
(should (string= " ()" (fingers-test-fingers-mark-inside-pair-strings " (abc)" 5 "(" ")")))
(should (string= " []" (fingers-test-fingers-mark-inside-pair-strings " [abc]" 5 "[" "]")))
(should (string= " ()" (fingers-test-fingers-mark-inside-pair-strings " ((a) b (c))" 8 "(" ")")))
(should (string= " ''" (fingers-test-fingers-mark-inside-pair-strings " 'abc'" 5 "'" "'")))
)
(ert-deftest fingers-test:fingers-mark-with-pair ()
(should (string= " " (fingers-test-fingers-mark-with-pair-strings " (abc)" 5 "(" ")")))
(should (string= " " (fingers-test-fingers-mark-with-pair-strings " [abc]" 5 "[" "]")))
(should (string= " " (fingers-test-fingers-mark-with-pair-strings " ((a) b (c))" 8 "(" ")")))
(should (string= " " (fingers-test-fingers-mark-with-pair-strings " 'abc'" 5 "'" "'")))
)
(ert-deftest fingers-test:fingers-mark-with-pair-and-whitespace ()
(should (string= "" (fingers-test-fingers-mark-with-pair-strings-and-whitespace " (abc)" 5 "(" ")")))
(should (string= "" (fingers-test-fingers-mark-with-pair-strings-and-whitespace " [abc]" 5 "[" "]")))
(should (string= "" (fingers-test-fingers-mark-with-pair-strings-and-whitespace " ((a) b (c))" 8 "(" ")")))
(should (string= "" (fingers-test-fingers-mark-with-pair-strings-and-whitespace " 'abc'" 5 "'" "'")))
)
(require 'fingers-qwerty)
(ert-deftest fingers-test:workman-to-qwerty ()
(should (string= "atcwkugd;ynmvjloqesfibrxhzp" (fingers-workman-to-qwerty "abcdefghijklmnopqrstuvwxyz;")))
(should (string= "aTc" (fingers-workman-to-qwerty "aBc")))
(should (string= "SPC" (fingers-workman-to-qwerty "SPC")))
(should (string= "RET" (fingers-workman-to-qwerty "RET")))
(should (string= "'" (fingers-workman-to-qwerty "'")))
(should (string= ";" (fingers-workman-to-qwerty "i")))
(should (string= "p" (fingers-workman-to-qwerty ";")))
(should (string= ":" (fingers-workman-to-qwerty "I")))
)
(require 'fingers-neo)
(ert-deftest fingers-test:workman-to-neo ()
(should (string= "uwpvrhoadkbmäntfxliegzcösüqjßy"
(fingers-workman-to-neo "abcdefghijklmnopqrstuvwxyz;/['")))
(should (string= "uWp" (fingers-workman-to-neo "aBc")))
(should (string= "SPC" (fingers-workman-to-neo "SPC")))
(should (string= "RET" (fingers-workman-to-neo "RET")))
(should (string= "y" (fingers-workman-to-neo "'")))
(should (string= "d" (fingers-workman-to-neo "i")))
(should (string= "q" (fingers-workman-to-neo ";")))
(should (string= "D" (fingers-workman-to-neo "I")))
)