emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastian Reuße" <seb@wirrsal.net>
To: emacs-orgmode@gnu.org
Cc: "Sebastian Reuße" <seb@wirrsal.net>
Subject: [PATCH 6/6] Improve ‘org-sort-list’ test
Date: Sun, 11 Mar 2018 16:43:52 +0100	[thread overview]
Message-ID: <20180311154352.16920-6-seb@wirrsal.net> (raw)
In-Reply-To: <20180311154352.16920-1-seb@wirrsal.net>

* 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"
-- 
2.16.2

  parent reply	other threads:[~2018-03-11 15:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-11 15:43 [PATCH 1/6] Fix alphabetic sorting for tables, plain lists Sebastian Reuße
2018-03-11 15:43 ` [PATCH 2/6] Fix alphabetic string matching operators Sebastian Reuße
2018-03-11 16:09   ` [PATCH] " Sebastian Reuße
2018-03-13  8:13     ` Nicolas Goaziou
2018-03-11 16:11   ` [PATCH 2/6] " Sebastian Reuße
2018-03-11 15:43 ` [PATCH 3/6] Fix org-table-sort-lines test Sebastian Reuße
2018-03-13  8:13   ` Nicolas Goaziou
2018-03-11 15:43 ` [PATCH 4/6] Fix string-collate-lessp shim Sebastian Reuße
2018-03-13  8:12   ` Nicolas Goaziou
2018-03-11 15:43 ` [PATCH 5/6] org-table-sort-lines: Fix case-sensitive sorting Sebastian Reuße
2018-03-13  8:13   ` Nicolas Goaziou
2018-03-11 15:43 ` Sebastian Reuße [this message]
2018-03-13  8:13   ` [PATCH 6/6] Improve ‘org-sort-list’ test Nicolas Goaziou
2018-03-13  8:12 ` [PATCH 1/6] Fix alphabetic sorting for tables, plain lists Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180311154352.16920-6-seb@wirrsal.net \
    --to=seb@wirrsal.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).