]> git.eshelyaron.com Git - emacs.git/commitdiff
Expand tests for image-type-from-file-header
authorStefan Kangas <stefan@marxist.se>
Sun, 24 Oct 2021 10:07:48 +0000 (12:07 +0200)
committerStefan Kangas <stefan@marxist.se>
Sun, 24 Oct 2021 10:14:32 +0000 (12:14 +0200)
* test/lisp/image-tests.el (image-tests--files): New defconst.
(image-tests--type-from-file-header): New defun.
(image-type-from-file-header-test/jpeg)
(image-type-from-file-header-test/pbm)
(image-type-from-file-header-test/png)
(image-type-from-file-header-test/svg)
(image-type-from-file-header-test/tiff)
(image-type-from-file-header-test/webp)
(image-type-from-file-header-test/xbm)
(image-type-from-file-header-test/xpm): New tests.
(image-type-from-file-header-test): Delete test.

test/lisp/image-tests.el

index c34c152cc99e7d235a2418c394691286745f4bc8..79b0014f60a9ddc31fbce62f6636ea7fab97fb34 100644 (file)
   (expand-file-name "images" data-directory)
   "Directory containing Emacs images.")
 
+(defconst image-tests--files
+  `((gif . ,(expand-file-name "test/data/image/black.gif"
+                               source-directory))
+    (jpeg . ,(expand-file-name "test/data/image/black.jpg"
+                               source-directory))
+    (pbm . ,(expand-file-name "splash.pbm"
+                              image-tests--emacs-images-directory))
+    (png . ,(expand-file-name "splash.png"
+                              image-tests--emacs-images-directory))
+    (svg . ,(expand-file-name "splash.svg"
+                              image-tests--emacs-images-directory))
+    (tiff . ,(expand-file-name
+              "nextstep/GNUstep/Emacs.base/Resources/emacs.tiff"
+              source-directory))
+    (webp . ,(expand-file-name "test/data/image/black.webp"
+                               source-directory))
+    (xbm . ,(expand-file-name "gnus/gnus.xbm"
+                              image-tests--emacs-images-directory))
+    (xpm . ,(expand-file-name "splash.xpm"
+                              image-tests--emacs-images-directory))))
+
 (ert-deftest image--set-property ()
   "Test `image--set-property' behavior."
   (let ((image (list 'image)))
                     (bound-and-true-p image-load-path)))
   (should (eq (image-type "foo.jpg") 'jpeg)))
 
-(ert-deftest image-type-from-file-header-test ()
+(defun image-tests--type-from-file-header (type)
   "Test image-type-from-file-header."
-  (should (eq (if (image-type-available-p 'svg) 'svg)
-             (image-type-from-file-header
-              (expand-file-name "splash.svg"
-                                image-tests--emacs-images-directory)))))
+  (should (eq (if (image-type-available-p type) type)
+              (image-type-from-file-header (cdr (assq type image-tests--files))))))
+
+(ert-deftest image-type-from-file-header-test/gif ()
+  (image-tests--type-from-file-header 'gif))
+
+(ert-deftest image-type-from-file-header-test/jpeg ()
+  (image-tests--type-from-file-header 'jpeg))
+
+(ert-deftest image-type-from-file-header-test/pbm ()
+  (image-tests--type-from-file-header 'pbm))
+
+(ert-deftest image-type-from-file-header-test/png ()
+  (image-tests--type-from-file-header 'png))
+
+(ert-deftest image-type-from-file-header-test/svg ()
+  (image-tests--type-from-file-header 'svg))
+
+(ert-deftest image-type-from-file-header-test/tiff ()
+  (image-tests--type-from-file-header 'tiff))
+
+(ert-deftest image-type-from-file-header-test/webp ()
+  (image-tests--type-from-file-header 'webp))
+
+(ert-deftest image-type-from-file-header-test/xbm ()
+  (image-tests--type-from-file-header 'xbm))
+
+(ert-deftest image-type-from-file-header-test/xpm ()
+  (image-tests--type-from-file-header 'xpm))
 
 (ert-deftest image-rotate ()
   "Test `image-rotate'."