mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Add new function file-name-with-extension
* doc/lispref/files.texi (File Name Components): Document it. * lisp/emacs-lisp/shortdoc.el (file-name): Ditto. * lisp/files.el (file-name-with-extension): New function.
This commit is contained in:
parent
1dba0ca278
commit
4f2765f6f1
5 changed files with 66 additions and 0 deletions
|
|
@ -1478,5 +1478,23 @@ The door of all subtleties!
|
|||
(buffer-substring (point-min) (point-max))
|
||||
nil nil)))))
|
||||
|
||||
(ert-deftest files-tests-file-name-with-extension-good ()
|
||||
"Test that `file-name-with-extension' succeeds with reasonable input."
|
||||
(should (string= (file-name-with-extension "Jack" "css") "Jack.css"))
|
||||
(should (string= (file-name-with-extension "Jack" ".css") "Jack.css"))
|
||||
(should (string= (file-name-with-extension "Jack.scss" "css") "Jack.css"))
|
||||
(should (string= (file-name-with-extension "/path/to/Jack.md" "org") "/path/to/Jack.org")))
|
||||
|
||||
(ert-deftest files-tests-file-name-with-extension-bad ()
|
||||
"Test that `file-name-with-extension' fails on malformed input."
|
||||
(should-error (file-name-with-extension nil nil))
|
||||
(should-error (file-name-with-extension "Jack" nil))
|
||||
(should-error (file-name-with-extension nil "css"))
|
||||
(should-error (file-name-with-extension "" ""))
|
||||
(should-error (file-name-with-extension "" "css"))
|
||||
(should-error (file-name-with-extension "Jack" ""))
|
||||
(should-error (file-name-with-extension "Jack" "."))
|
||||
(should-error (file-name-with-extension "/is/a/directory/" "css")))
|
||||
|
||||
(provide 'files-tests)
|
||||
;;; files-tests.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue