emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-matchit d75d41d7b3 197/244: add unit test for c


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit d75d41d7b3 197/244: add unit test for c
Date: Thu, 6 Jan 2022 02:59:01 -0500 (EST)

branch: elpa/evil-matchit
commit d75d41d7b33ff12025af637a8272e30c0226489e
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    add unit test for c
---
 tests/evil-matchit-tests.el | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tests/evil-matchit-tests.el b/tests/evil-matchit-tests.el
index f7d9a9a01a..277f4df229 100644
--- a/tests/evil-matchit-tests.el
+++ b/tests/evil-matchit-tests.el
@@ -128,5 +128,37 @@
       (should (string= (thing-at-point 'symbol) "/p"))
 
       (should (eq major-mode 'html-mode)))))
+
+(ert-deftest evilmi-test-c ()
+  (let* ((str "#ifdef CONFIG_COMPAT\n#ifndef TEST1\nstruct mtip_s {\n  int 
v1;\n}\n#endif\n#endif\nstatic int fn1()\n{\nprintf(\"hello world\");\n}\nint a 
= 3;"))
+    (with-temp-buffer
+      (insert str)
+      (c-mode)
+
+      ;; jump from start
+      (goto-char (point-min))
+      ;; test #ifdef
+      (evilmi-jump-items)
+      (should (string= "endif" (thing-at-point 'symbol)))
+      ;; test #ifndef
+      (forward-line -1)
+      (evilmi-jump-items)
+      (should (eq (point) (line-beginning-position)))
+      (should (eq (following-char) ?#))
+      (forward-char)
+      (should (string= "ifndef" (thing-at-point 'symbol)))
+
+      ;; jump from function begin to end
+      (goto-char (point-min))
+      (search-forward "static int");
+      (evilmi-jump-items)
+      (should (eq (following-char) ?}))
+      (should (string= (evilmi-sdk-curline) "}"))
+      ;; jump back
+      (evilmi-jump-items)
+      (should (eq (following-char) ?{))
+      (should (string= (evilmi-sdk-curline) "{"))
+
+      (should (eq major-mode 'c-mode)))))
 (ert-run-tests-batch-and-exit)
 ;;; evil-matchit-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]