Skip to content

Commit

Permalink
test: Add unit tests for Error implementations
Browse files Browse the repository at this point in the history
Mainly to flag if they're deleted accidentally
  • Loading branch information
alexpovel committed Jun 16, 2023
1 parent 211535a commit d5901ff
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,3 +525,20 @@ impl Display for SortedStringCreationError {
}
}
}

#[cfg(test)]
mod tests {
use super::*;
use rstest::rstest;
use std::error::Error;

/// Pretty useless test; just have it so removing `Error` is flagged and would be
/// noticed.
#[rstest]
#[case(Box::new(SortedStringCreationError::NotSorted))]
#[case(Box::new(SortedStringCreationError::EmptyHaystack))]
#[case(Box::new(SearchError(Range { start: 0, end: 1 })))]
fn test_error_trait_implementations_are_present(#[case] err: Box<dyn Error>) {
assert!(!err.to_string().is_empty());
}
}

0 comments on commit d5901ff

Please sign in to comment.