From 4b19029a72ebd22002be33f29a4168e61fc1ec6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Date: Sun, 11 Mar 2018 16:43:52 +0100 Subject: [PATCH] =?UTF-8?q?Improve=20=E2=80=98org-sort-list=E2=80=99=20tes?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test-org-list.el (test-org-list/sort): Take case-sensitive vs. insensitive sorting into account. --- testing/lisp/test-org-list.el | 36 +++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index 866ee4799..e0c448ce9 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -1015,16 +1015,32 @@ (ert-deftest test-org-list/sort () "Test `org-sort-list'." ;; Sort alphabetically. - (should - (equal "- abc\n- def\n- xyz\n" - (org-test-with-temp-text "- def\n- xyz\n- abc\n" - (org-sort-list nil ?a) - (buffer-string)))) - (should - (equal "- xyz\n- def\n- abc\n" - (org-test-with-temp-text "- def\n- xyz\n- abc\n" - (org-sort-list nil ?A) - (buffer-string)))) + (let ((original-string-collate-lessp (symbol-function 'string-collate-lessp))) + (cl-letf (((symbol-function 'string-collate-lessp) + (lambda (s1 s2 &optional locale ignore-case) + (funcall original-string-collate-lessp + s1 s2 "C" ignore-case)))) + (should + (equal "- abc\n- def\n- XYZ\n" + (org-test-with-temp-text "- def\n- XYZ\n- abc\n" + (org-sort-list nil ?a) + (buffer-string)))) + (should + (equal "- XYZ\n- def\n- abc\n" + (org-test-with-temp-text "- def\n- XYZ\n- abc\n" + (org-sort-list nil ?A) + (buffer-string)))) + ;; Sort alphabetically (with case). + (should + (equal "- C\n- a\n- b\n" + (org-test-with-temp-text "- b\n- C\n- a\n" + (org-sort-list t ?a) + (buffer-string)))) + (should + (equal "- b\n- a\n- C\n" + (org-test-with-temp-text "- b\n- C\n- a\n" + (org-sort-list t ?A) + (buffer-string)))))) ;; Sort numerically. (should (equal "- 1\n- 2\n- 10\n"