branch: elpa/evil-numbers
commit db598cf86af6ea1512c0993ec0123fc45b94db31
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>

    Tests: add regression test for bug #24
    
    Ensures hexadecimal case is preserved when incrementing/decrementing.
---
 tests/evil-numbers-tests.el | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/tests/evil-numbers-tests.el b/tests/evil-numbers-tests.el
index 7a4247179d0..fdd5e3bcfb5 100644
--- a/tests/evil-numbers-tests.el
+++ b/tests/evil-numbers-tests.el
@@ -6,7 +6,7 @@
 
 ;; See: `evil-numbers-tests.sh' for launching this script.
 
-;; TODO: tests that handle bugs: #20, #24, #26, #27.
+;; TODO: tests that handle bugs: #20, #26, #27.
 ;; Bugs fixed in:
 ;; c37a4cf92a9cf8aa9f8bd752ea856a9d1bc6c84c
 
@@ -336,6 +336,42 @@
         "a|")
       (should (equal text-expected (buffer-string))))))
 
+;; See bug #24.
+(ert-deftest simple-hex-case-preserved ()
+  "Check that hexadecimal case is preserved when incrementing/decrementing."
+  ;; Lowercase hex should stay lowercase.
+  (let ((text-expected " 0xf1| ")
+        (text-initial " 0xf0 "))
+    (with-evil-numbers-test text-initial
+      (simulate-input
+        (kbd "C-a")
+        "a|")
+      (should (equal text-expected (buffer-string)))))
+  ;; Uppercase hex should stay uppercase.
+  (let ((text-expected " 0xF1| ")
+        (text-initial " 0xF0 "))
+    (with-evil-numbers-test text-initial
+      (simulate-input
+        (kbd "C-a")
+        "a|")
+      (should (equal text-expected (buffer-string)))))
+  ;; Numeric-only hex (no alpha) should become lowercase (default).
+  (let ((text-expected " 0xa| ")
+        (text-initial " 0x9 "))
+    (with-evil-numbers-test text-initial
+      (simulate-input
+        (kbd "C-a")
+        "a|")
+      (should (equal text-expected (buffer-string)))))
+  ;; Test decrement preserves case too.
+  (let ((text-expected " 0xef| ")
+        (text-initial " 0xf0 "))
+    (with-evil-numbers-test text-initial
+      (simulate-input
+        (kbd "C-x")
+        "a|")
+      (should (equal text-expected (buffer-string))))))
+
 ;; See bug #21.
 (ert-deftest selected-line-cursor-at-end ()
   "Line selection increments numbers before the cursor."

Reply via email to