[librsvg: 3/15] tests: Add test for rsvg-convert --help



commit eb1e5cf737a2cf9ff38e926b5eb45bee97ddccf3
Author: Sven Neumann <sven svenfoo org>
Date:   Mon Feb 3 22:16:50 2020 +0100

    tests: Add test for rsvg-convert --help

 tests/src/cmdline/rsvg_convert.rs | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/tests/src/cmdline/rsvg_convert.rs b/tests/src/cmdline/rsvg_convert.rs
index 57205737..89ffad29 100644
--- a/tests/src/cmdline/rsvg_convert.rs
+++ b/tests/src/cmdline/rsvg_convert.rs
@@ -1,31 +1,45 @@
 extern crate assert_cmd;
 extern crate predicates;
 
+use assert_cmd::assert::Assert;
+use assert_cmd::Command;
 use predicates::prelude::*;
 use std::path::Path;
 
 struct RsvgConvert {
-    cmd: assert_cmd::Command,
+    cmd: Command,
 }
 
 fn location() -> &'static Path {
     match option_env!("LIBRSVG_BUILD_DIR") {
         Some(dir) => Path::new(dir),
-        None => Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap()
+        None => Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap(),
     }
 }
 
 impl RsvgConvert {
     fn new() -> Self {
         let path = location().join("rsvg-convert");
-        println!("{:?}", path);
-        RsvgConvert { cmd: assert_cmd::Command::new(path) }
+        RsvgConvert {
+            cmd: Command::new(path),
+        }
     }
+
+    fn assert_arg(self: &mut Self, arg: &str) -> Assert {
+        self.cmd.arg(arg).assert().success()
+    }
+}
+
+#[test]
+fn help_option() {
+    let expected = predicate::str::starts_with("Usage:");
+    RsvgConvert::new().assert_arg("-?").stdout(expected.clone());
+    RsvgConvert::new().assert_arg("--help").stdout(expected);
 }
 
 #[test]
-fn version() {
+fn version_option() {
     let expected = predicate::str::starts_with("rsvg-convert version ");
-    RsvgConvert::new().cmd.arg("-v").assert().success().stdout(expected.clone());
-    RsvgConvert::new().cmd.arg("--version").assert().success().stdout(expected);
+    RsvgConvert::new().assert_arg("-v").stdout(expected.clone());
+    RsvgConvert::new().assert_arg("--version").stdout(expected);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]