diff --git a/src/time_unit/mod.rs b/src/time_unit/mod.rs index b3d19c2..1a89cd0 100644 --- a/src/time_unit/mod.rs +++ b/src/time_unit/mod.rs @@ -297,6 +297,7 @@ where fn ordinals_from_root_specifier(root_specifier: &RootSpecifier) -> Result { let ordinals = match root_specifier { RootSpecifier::Specifier(specifier) => Self::ordinals_from_specifier(specifier)?, + RootSpecifier::Period(_, 0) => Err(ErrorKind::Expression(format!("range step cannot be zero")))?, RootSpecifier::Period(start, step) => { let base_set = match start { // A point prior to a period implies a range whose start is the specified diff --git a/tests/lib.rs b/tests/lib.rs index e4270df..7b8091b 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -221,6 +221,12 @@ mod tests { ); } + #[test] + fn test_invalid_step() { + let expression = "0/0 * * * *"; + assert!(Schedule::from_str(expression).is_err()); + } + #[test] fn test_time_unit_spec_years() { let expression = "* * * * * * 2015-2044";