summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNicolas Petton <nicolas@petton.fr>2015-06-04 18:20:18 +0200
committerNicolas Petton <nicolas@petton.fr>2015-06-04 18:27:54 +0200
commit41a929c5ae1110e39f94c018dc2b3e224e884f18 (patch)
tree6fc7c92f12861766329c6d4daac52bf9547a77ea /test
parent285260fce84c945acb588a7c70d3df5d8271f586 (diff)
downloademacs-41a929c5ae1110e39f94c018dc2b3e224e884f18.tar.gz
Add new function string-greaterp
* lisp/subr.el (string-greaterp): New function. Also aliased to `string>'. * test/automated/subr-tests.el (string-comparison-test): Add unit tests for `string>'and `string<'. * src/fns.c (string-lessp): Better docstring.
Diffstat (limited to 'test')
-rw-r--r--test/automated/subr-tests.el24
1 files changed, 23 insertions, 1 deletions
diff --git a/test/automated/subr-tests.el b/test/automated/subr-tests.el
index d29efc6f330..28a423f5ee8 100644
--- a/test/automated/subr-tests.el
+++ b/test/automated/subr-tests.el
@@ -2,7 +2,8 @@
;; Copyright (C) 2015 Free Software Foundation, Inc.
-;; Author: Oleh Krehel <ohwoeowho@gmail.com>
+;; Author: Oleh Krehel <ohwoeowho@gmail.com>,
+;; Nicolas Petton <nicolas@petton.fr>
;; Keywords:
;; This file is part of GNU Emacs.
@@ -60,5 +61,26 @@
(quote
(0 font-lock-keyword-face))))))))
+(ert-deftest string-comparison-test ()
+ (should (string-lessp "abc" "acb"))
+ (should (string-lessp "aBc" "abc"))
+ (should (string-lessp "abc" "abcd"))
+ (should (string-lessp "abc" "abcd"))
+ (should-not (string-lessp "abc" "abc"))
+ (should-not (string-lessp "" ""))
+
+ (should (string-greaterp "acb" "abc"))
+ (should (string-greaterp "abc" "aBc"))
+ (should (string-greaterp "abcd" "abc"))
+ (should (string-greaterp "abcd" "abc"))
+ (should-not (string-greaterp "abc" "abc"))
+ (should-not (string-greaterp "" ""))
+
+ ;; Symbols are also accepted
+ (should (string-lessp 'abc 'acb))
+ (should (string-lessp "abc" 'acb))
+ (should (string-greaterp 'acb 'abc))
+ (should (string-greaterp "acb" 'abc)))
+
(provide 'subr-tests)
;;; subr-tests.el ends here