diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2016-02-21 15:32:45 +1100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2016-02-21 15:32:45 +1100 |
commit | 71783e90a46ca913ea2c334cdc8cb24cd74055f8 (patch) | |
tree | 3c35b883caea4392789d6c991a08bb74475407ad /test/src | |
parent | 1ba50a0d8cbef6686ecf752583832e7bbb9137ef (diff) | |
download | emacs-71783e90a46ca913ea2c334cdc8cb24cd74055f8.tar.gz |
Add the string-numeric-lessp function
* doc/lispref/strings.texi (Text Comparison): Document
`string-numerical-lessp'.
* src/fns.c (Fstring_numeric_lessp): New function.
(gather_number_from_string): Helper function for that function.
* test/src/fns-tests.el (fns-tests-string-numeric-lessp): Add tests.
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/fns-tests.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 762f7bdd94f..0c6edb89252 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el @@ -191,3 +191,20 @@ (string-collate-lessp a b (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8"))))) '("Adrian" "Ævar" "Agustín" "Eli")))) + +(ert-deftest fns-tests-string-numeric-lessp () + (should (string-numeric-lessp "foo2.png" "foo12.png")) + (should (not (string-numeric-lessp "foo12.png" "foo2.png"))) + (should (string-numeric-lessp "foo12.png" "foo20000.png")) + (should (not (string-numeric-lessp "foo20000.png" "foo12.png"))) + (should (string-numeric-lessp "foo.png" "foo2.png")) + (should (not (string-numeric-lessp "foo2.png" "foo.png"))) + (should (equal (sort '("foo12.png" "foo2.png" "foo1.png") + 'string-numeric-lessp) + '("foo1.png" "foo2.png" "foo12.png"))) + (should (string-numeric-lessp "foo2" "foo1234")) + (should (not (string-numeric-lessp "foo1234" "foo2"))) + (should (string-numeric-lessp "foo.png" "foo2")) + (should (string-numeric-lessp "foo1.25.5.png" "foo1.125.5")) + (should (string-numeric-lessp "2" "1245")) + (should (not (string-numeric-lessp "1245" "2")))) |