From 5c86f81adca3b7e2256ade3af09bbddc53a26c4d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 16 Jun 2017 19:18:37 +0530 Subject: Deduplicate extraction of tags of test cases. * tests/exiftool-tests.el (exiftool-tests--tags): New variable. (read-write-test, copy-all-test, copy-some-test): Reference exiftool-tests--tags. --- tests/exiftool-tests.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/exiftool-tests.el b/tests/exiftool-tests.el index ecb4f15..6f14ffe 100644 --- a/tests/exiftool-tests.el +++ b/tests/exiftool-tests.el @@ -37,6 +37,12 @@ ("Subject" . "foo:bar") ("Description" . "foo: bar"))) +(defvar exiftool-tests--tags + (mapcar (cl-function + (lambda ((tag . value)) + tag)) + exiftool-tests--tag-value)) + (require 'exiftool) (require 'cl-lib) (require 'ert) @@ -53,7 +59,7 @@ (ert-deftest read-write-test () (with-temp-test-file "test1.png" temp-file (apply 'exiftool-write temp-file exiftool-tests--tag-value) - (should (equal (apply 'exiftool-read temp-file (mapcar 'car exiftool-tests--tag-value)) + (should (equal (apply 'exiftool-read temp-file exiftool-tests--tags) exiftool-tests--tag-value)))) (ert-deftest delete-test () @@ -70,19 +76,17 @@ (with-temp-test-file "test2.png" temp-2 (apply 'exiftool-write temp-1 exiftool-tests--tag-value) (exiftool-copy temp-1 temp-2) - (let ((tags (mapcar 'car exiftool-tests--tag-value))) - (should (equal (apply 'exiftool-read temp-1 tags) - (apply 'exiftool-read temp-2 tags))))))) + (should (equal (apply 'exiftool-read temp-1 exiftool-tests--tags) + (apply 'exiftool-read temp-2 exiftool-tests--tags)))))) (ert-deftest copy-some-test () (with-temp-test-file "test1.png" temp-1 (with-temp-test-file "test2.png" temp-2 (apply 'exiftool-write temp-1 exiftool-tests--tag-value) - (let* ((all-tags (mapcar 'car exiftool-tests--tag-value)) - (some-tags (cl-subseq all-tags 2))) + (let ((some-tags (cl-subseq exiftool-tests--tags 2))) (apply 'exiftool-copy temp-1 temp-2 some-tags) - (should (and (not (equal (apply 'exiftool-read temp-1 all-tags) - (apply 'exiftool-read temp-2 all-tags))) + (should (and (not (equal (apply 'exiftool-read temp-1 exiftool-tests--tags) + (apply 'exiftool-read temp-2 exiftool-tests--tags))) (equal (apply 'exiftool-read temp-1 some-tags) (apply 'exiftool-read temp-2 some-tags)))))))) -- cgit v1.2.3