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

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

[elpa] externals/denote a0188e7cba 05/11: Expand tests to also cover alp


From: ELPA Syncer
Subject: [elpa] externals/denote a0188e7cba 05/11: Expand tests to also cover alphanumeric child sequences
Date: Sun, 12 Jan 2025 06:58:06 -0500 (EST)

branch: externals/denote
commit a0188e7cba94fe8caf2c0c309dc4a4218564ff5e
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Expand tests to also cover alphanumeric child sequences
---
 tests/denote-test.el | 46 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 7 deletions(-)

diff --git a/tests/denote-test.el b/tests/denote-test.el
index 9a5fa808d5..b36f098d14 100644
--- a/tests/denote-test.el
+++ b/tests/denote-test.el
@@ -594,8 +594,9 @@ does not involve the time zone."
 
 ;; TODO 2024-12-31: Maybe we can share some state between tests?  It
 ;; is expensive to create those files over and over.
-(ert-deftest dt-denote-sequence--get-new-child ()
-  "Make sure `denote-sequence--get-new-child' gets the child of a sequence."
+(ert-deftest dt-denote-sequence--get-new-child-numeric ()
+  "Make sure `denote-sequence--get-new-child' gets the child of a sequence.
+This is done using the numeric `denote-sequence-scheme'."
   (let* ((denote-directory (expand-file-name "denote-test" 
temporary-file-directory))
          (files
           (mapcar
@@ -613,9 +614,7 @@ does not involve the time zone."
              "20241230T075023==1=1=2--test__testing.txt"
              "20241230T075023==1=2--test__testing.txt"
              "20241230T075023==1=2=1--test__testing.txt"
-             "20241230T075023==2--test__testing.txt"
-             "20241230T075023==45--test__testing.txt"
-             "20241230T075023==45=1--test__testing.txt")))
+             "20241230T075023==2--test__testing.txt")))
          (sequences (denote-sequence-get-all-sequences files)))
     (let ((denote-sequence-scheme 'numeric))
       (should
@@ -625,8 +624,41 @@ does not involve the time zone."
         (equal (denote-sequence--get-new-child "1=1=2" sequences) "1=1=2=1")
         (equal (denote-sequence--get-new-child "1=2" sequences) "1=2=2")
         (equal (denote-sequence--get-new-child "1=2=1" sequences) "1=2=1=1")
-        (equal (denote-sequence--get-new-child "2" sequences) "2=1")
-        (equal (denote-sequence--get-new-child "45" sequences) "45=2")))
+        (equal (denote-sequence--get-new-child "2" sequences) "2=1")))
+      (should-error (denote-sequence--get-new-child "3" sequences)))
+    (delete-directory denote-directory :delete-contents-as-well)))
+
+(ert-deftest dt-denote-sequence--get-new-child-alphanumeric ()
+  "Make sure `denote-sequence--get-new-child' gets the child of a sequence.
+This is done using the alphanumeric `denote-sequence-scheme'."
+  (let* ((denote-directory (expand-file-name "denote-test" 
temporary-file-directory))
+         (files
+          (mapcar
+           (lambda (file)
+             (let ((path (expand-file-name file (denote-directory))))
+               (if (file-exists-p path)
+                   path
+                 (with-current-buffer (find-file-noselect path)
+                   (save-buffer)
+                   (kill-buffer (current-buffer)))
+                 path)))
+           '("20241230T075004==1--some-new-title__testing.txt"
+             "20241230T075023==1a--child-of-note__testing.txt"
+             "20241230T075023==1a1--test__testing.txt"
+             "20241230T075023==1a2--test__testing.txt"
+             "20241230T075023==1b--test__testing.txt"
+             "20241230T075023==1b1--test__testing.txt"
+             "20241230T075023==2--test__testing.txt")))
+         (sequences (denote-sequence-get-all-sequences files)))
+    (let ((denote-sequence-scheme 'alphanumeric))
+      (should
+       (and
+        (equal (denote-sequence--get-new-child "1" sequences) "1c")
+        (equal (denote-sequence--get-new-child "1a" sequences) "1a3")
+        (equal (denote-sequence--get-new-child "1a2" sequences) "1a2a")
+        (equal (denote-sequence--get-new-child "1b" sequences) "1b2")
+        (equal (denote-sequence--get-new-child "1b1" sequences) "1b1a")
+        (equal (denote-sequence--get-new-child "2" sequences) "2a")))
       (should-error (denote-sequence--get-new-child "3" sequences)))
     (delete-directory denote-directory :delete-contents-as-well)))
 



reply via email to

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