branch: externals/scanner
commit 1b1d40b026fadd831b7433580a2d9b4d5031a988
Author: Raffael Stocker <r.stoc...@mnet-mail.de>
Commit: Raffael Stocker <r.stoc...@mnet-mail.de>

    add tests for size conversion functions
---
 scanner-test.el | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/scanner-test.el b/scanner-test.el
index c408c57a1a..18f4deef40 100644
--- a/scanner-test.el
+++ b/scanner-test.el
@@ -135,6 +135,29 @@
     (should (equal '("txt") (scanner-select-outputs '("txt"))))
     (should (equal '("pdf" "txt") (scanner-select-outputs '("pdf" "txt"))))))
 
+(ert-deftest scanner--cm-to-pixels ()
+  "Test the cm to pixel conversion."
+  (should (= 100 (scanner--cm-to-pixels 2.54 100)))
+  (should (= 600 (scanner--cm-to-pixels 2.54 600)))
+  (should (= 0 (scanner--cm-to-pixels 2.54 0)))
+  (should (= 354 (scanner--cm-to-pixels 3 300)))
+  (should (= 300 (scanner--cm-to-pixels 2.54508 300))))
+
+(ert-deftest scanner--corner-pixels ()
+  "Test the paper size to corner coordinates conversion."
+  (should (equal '(0 0 35078 25393) (scanner--corner-pixels '(297 215) 300))))
+
+(ert-deftest scanner--keyword-string ()
+  "Test the keyword to string conversion."
+  (should (string= "keyword" (scanner--keyword-string :keyword)))
+  (should (string= "" (scanner--keyword-string :))))
+
+(ert-deftest scanner--process-unpaper-size ()
+  "Test paper size parsing."
+  (should (eq nil (scanner--process-unpaper-size "none")))
+  (should (eq :the-size (scanner--process-unpaper-size ":the-size")))
+  (should (string= "297cm,210cm" (scanner--process-unpaper-size 
"297cm,210cm"))))
+
 (provide 'scanner-test)
 
 

Reply via email to