From 2e4d2da12bb0abe1ffcb61b70c5047ec71303f47 Mon Sep 17 00:00:00 2001 From: JuanLeon Lahoz Date: Mon, 24 May 2021 15:52:45 +0200 Subject: [PATCH] fix: allow negative values in min and max arguments --- src/app.rs | 2 ++ tests/integration_tests.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/app.rs b/src/app.rs index 790381d..d5fac64 100644 --- a/src/app.rs +++ b/src/app.rs @@ -24,6 +24,7 @@ fn add_min_max(app: App) -> App { Arg::new("max") .long("max") .short('M') + .allow_hyphen_values(true) .about("Filter out values bigger than this") .takes_value(true), ) @@ -31,6 +32,7 @@ fn add_min_max(app: App) -> App { Arg::new("min") .long("min") .short('m') + .allow_hyphen_values(true) .about("Filter out values smaller than this") .takes_value(true), ) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 1a039e8..f907fd2 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -166,3 +166,19 @@ fn test_plot() { Err(_) => assert!(false, "Could not create temp file"), } } + +#[test] +fn test_hist_negative_min() { + let mut cmd = Command::cargo_bin("lowcharts").unwrap(); + cmd.arg("hist") + .arg("--min") + .arg("-1") + .arg("--max") + .arg("10.1") + .write_stdin("4.2\n2.4\n-2\n") + .assert() + .success() + .stdout(predicate::str::contains( + "Samples = 2; Min = 2.4; Max = 4.2", + )); +}