summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorClementTsang <cjhtsang@uwaterloo.ca>2020-03-08 22:19:57 -0400
committerClementTsang <cjhtsang@uwaterloo.ca>2020-03-08 22:27:41 -0400
commit78a05bc68377497dfd52eaee37c7a5e3bedd71b1 (patch)
tree8ad04df2cd67b930b994d352687a0893860b9537 /tests
parentf70cf02414a5263c000f06c1b36ee19e11bf23a5 (diff)
Fixes bug with too large inputs causing a panic
We would prefer a more graceful error message stating what went wrong. Caught by the Travis test.
Diffstat (limited to 'tests')
-rw-r--r--tests/arg_tests.rs (renamed from tests/arg_rate_tests.rs)52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/arg_rate_tests.rs b/tests/arg_tests.rs
index 7f22431c..f184b811 100644
--- a/tests/arg_rate_tests.rs
+++ b/tests/arg_tests.rs
@@ -35,6 +35,58 @@ fn test_small_rate() -> Result<(), Box<dyn std::error::Error>> {
}
#[test]
+fn test_large_default_time() -> Result<(), Box<dyn std::error::Error>> {
+ Command::new(get_os_binary_loc())
+ .arg("-t")
+ .arg("18446744073709551616")
+ .assert()
+ .failure()
+ .stderr(predicate::str::contains(
+ "Please set your default value to be at most unsigned INT_MAX.",
+ ));
+ Ok(())
+}
+
+#[test]
+fn test_small_default_time() -> Result<(), Box<dyn std::error::Error>> {
+ Command::new(get_os_binary_loc())
+ .arg("-t")
+ .arg("900")
+ .assert()
+ .failure()
+ .stderr(predicate::str::contains(
+ "Please set your default value to be at least 30 seconds.",
+ ));
+ Ok(())
+}
+
+#[test]
+fn test_large_delta_time() -> Result<(), Box<dyn std::error::Error>> {
+ Command::new(get_os_binary_loc())
+ .arg("-d")
+ .arg("18446744073709551616")
+ .assert()
+ .failure()
+ .stderr(predicate::str::contains(
+ "Please set your time delta to be at most unsigned INT_MAX.",
+ ));
+ Ok(())
+}
+
+#[test]
+fn test_small_delta_time() -> Result<(), Box<dyn std::error::Error>> {
+ Command::new(get_os_binary_loc())
+ .arg("-d")
+ .arg("900")
+ .assert()
+ .failure()
+ .stderr(predicate::str::contains(
+ "Please set your time delta to be at least 1 second.",
+ ));
+ Ok(())
+}
+
+#[test]
fn test_large_rate() -> Result<(), Box<dyn std::error::Error>> {
Command::new(get_os_binary_loc())
.arg("-r")