Improve ‘org-sort-list’ test
* test-org-list.el (test-org-list/sort): Take case-sensitive vs. insensitive sorting into account.
This commit is contained in:
parent
88bf8aef28
commit
4b19029a72
|
@ -1015,16 +1015,32 @@
|
||||||
(ert-deftest test-org-list/sort ()
|
(ert-deftest test-org-list/sort ()
|
||||||
"Test `org-sort-list'."
|
"Test `org-sort-list'."
|
||||||
;; Sort alphabetically.
|
;; Sort alphabetically.
|
||||||
(should
|
(let ((original-string-collate-lessp (symbol-function 'string-collate-lessp)))
|
||||||
(equal "- abc\n- def\n- xyz\n"
|
(cl-letf (((symbol-function 'string-collate-lessp)
|
||||||
(org-test-with-temp-text "- def\n- xyz\n- abc\n"
|
(lambda (s1 s2 &optional locale ignore-case)
|
||||||
(org-sort-list nil ?a)
|
(funcall original-string-collate-lessp
|
||||||
(buffer-string))))
|
s1 s2 "C" ignore-case))))
|
||||||
(should
|
(should
|
||||||
(equal "- xyz\n- def\n- abc\n"
|
(equal "- abc\n- def\n- XYZ\n"
|
||||||
(org-test-with-temp-text "- def\n- xyz\n- abc\n"
|
(org-test-with-temp-text "- def\n- XYZ\n- abc\n"
|
||||||
(org-sort-list nil ?A)
|
(org-sort-list nil ?a)
|
||||||
(buffer-string))))
|
(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.
|
;; Sort numerically.
|
||||||
(should
|
(should
|
||||||
(equal "- 1\n- 2\n- 10\n"
|
(equal "- 1\n- 2\n- 10\n"
|
||||||
|
|
Loading…
Reference in New Issue