diff options
| author | Lars Ingebrigtsen | 2016-02-21 15:32:45 +1100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-02-21 15:32:45 +1100 |
| commit | 71783e90a46ca913ea2c334cdc8cb24cd74055f8 (patch) | |
| tree | 3c35b883caea4392789d6c991a08bb74475407ad /test/src | |
| parent | 1ba50a0d8cbef6686ecf752583832e7bbb9137ef (diff) | |
| download | emacs-71783e90a46ca913ea2c334cdc8cb24cd74055f8.tar.gz emacs-71783e90a46ca913ea2c334cdc8cb24cd74055f8.zip | |
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 @@ | |||
| 191 | (string-collate-lessp | 191 | (string-collate-lessp |
| 192 | a b (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8"))))) | 192 | a b (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8"))))) |
| 193 | '("Adrian" "Ævar" "Agustín" "Eli")))) | 193 | '("Adrian" "Ævar" "Agustín" "Eli")))) |
| 194 | |||
| 195 | (ert-deftest fns-tests-string-numeric-lessp () | ||
| 196 | (should (string-numeric-lessp "foo2.png" "foo12.png")) | ||
| 197 | (should (not (string-numeric-lessp "foo12.png" "foo2.png"))) | ||
| 198 | (should (string-numeric-lessp "foo12.png" "foo20000.png")) | ||
| 199 | (should (not (string-numeric-lessp "foo20000.png" "foo12.png"))) | ||
| 200 | (should (string-numeric-lessp "foo.png" "foo2.png")) | ||
| 201 | (should (not (string-numeric-lessp "foo2.png" "foo.png"))) | ||
| 202 | (should (equal (sort '("foo12.png" "foo2.png" "foo1.png") | ||
| 203 | 'string-numeric-lessp) | ||
| 204 | '("foo1.png" "foo2.png" "foo12.png"))) | ||
| 205 | (should (string-numeric-lessp "foo2" "foo1234")) | ||
| 206 | (should (not (string-numeric-lessp "foo1234" "foo2"))) | ||
| 207 | (should (string-numeric-lessp "foo.png" "foo2")) | ||
| 208 | (should (string-numeric-lessp "foo1.25.5.png" "foo1.125.5")) | ||
| 209 | (should (string-numeric-lessp "2" "1245")) | ||
| 210 | (should (not (string-numeric-lessp "1245" "2")))) | ||