]> gitweb.hhaalo.de Git - scantopdf.git/commitdiff
refactor if to one line
authorBastian Dehn <hhaalo@arcor.de>
Sun, 6 Jul 2025 10:00:10 +0000 (12:00 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 6 Jul 2025 10:00:10 +0000 (12:00 +0200)
src/scanbasic.sh
tests/scanbasic.bats

index 3352d962c79761dec1d31c94887b115b7c1cf97f..b273fa64206a4f4c0854466a70695c23ae935dba 100644 (file)
@@ -226,10 +226,10 @@ scantopdf() {
                || errlog "scan error" \
                || return $?
 
-       if [ "$output" == "multi" ]; then
-               createmultipdfs || return $?
-               return
-       fi
+       [ "$output" != "multi" ] \
+               || createmultipdfs \
+               && return 0 \
+               || return $?
 
        createonepdf "$output" \
                || return $?
index 54bc51582e1512ad3277b991a4a12340f6f5d7cf..069db782d3a3bd3f00eeba3ad760120dd85c3840 100755 (executable)
@@ -286,3 +286,29 @@ setup() {
 
        assert_success
 }
+
+@test "should failure scantopdf with multi" {
+       scanimage() {
+               :
+       }
+       createmultipdfs() {
+               return 1
+       }
+
+       run scantopdf "Color" "1" "multi"
+
+       assert_failure
+}
+
+@test "should success scantopdf with multi" {
+       scanimage() {
+               :
+       }
+       createmultipdfs() {
+               :
+       }
+
+       run scantopdf "Color" "1" "multi"
+
+       assert_success
+}