Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle zero range step #110

Merged
merged 2 commits into from
Sep 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/time_unit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ where
fn ordinals_from_root_specifier(root_specifier: &RootSpecifier) -> Result<OrdinalSet, Error> {
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
Expand Down
6 changes: 6 additions & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down