master 56b411c002f: Add a few more tests for 'make-empty-file'

Philipp Stephani <[email protected]>
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: master
commit 56b411c002f8a9d1e78fedbf11a2e1eb58393cb9
Author: Philipp Stephani <[email protected]>
Commit: Philipp Stephani <[email protected]>

    Add a few more tests for 'make-empty-file'
    
    * test/lisp/files-tests.el (files-tests--make-empty-file--no-parent)
    (files-tests--make-empty-file--parent): New unit tests.
---
 test/lisp/files-tests.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 9f657cf7b26..ccfed997734 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -2302,6 +2302,24 @@ Prompt users for any modified buffer with `buffer-offer-save' non-nil."
   (should (file-expand-wildcards
            (concat (directory-file-name default-directory) "*/"))))
 
+(ert-deftest files-tests--make-empty-file--no-parent ()
+  (ert-with-temp-directory base
+    (let ((file (file-name-concat base "file.txt")))
+      (make-empty-file file)
+      (let ((attrs (file-attributes file)))
+        (should attrs)  ; file exists
+        (should-not (file-attribute-type attrs))  ; file is regular
+        (should (zerop (file-attribute-size attrs)))))))
+
+(ert-deftest files-tests--make-empty-file--parent ()
+  (ert-with-temp-directory base
+    (let ((file (file-name-concat base "dir" "file.txt")))
+      (make-empty-file file :parents)
+      (let ((attrs (file-attributes file)))
+        (should attrs)  ; file exists
+        (should-not (file-attribute-type attrs))  ; file is regular
+        (should (zerop (file-attribute-size attrs)))))))
+
 (ert-deftest files-tests--make-empty-file--exists ()
   (ert-with-temp-directory base
     (let ((file (file-name-concat base "file.txt")))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.