Skip to content

Commit

Permalink
Merge pull request #350 from dtolnay/rawsource
Browse files Browse the repository at this point in the history
Add test of r#source that is not Error::source
  • Loading branch information
dtolnay authored Nov 4, 2024
2 parents 2e96c84 + b2df5d5 commit ef191b1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,20 @@ error_from_macro! {
#[error("Something")]
Variant(#[from] io::Error)
}

#[test]
fn test_not_source() {
#[derive(Error, Debug)]
#[error("{source} ==> {destination}")]
pub struct NotSource {
r#source: char,
destination: char,
}

let error = NotSource {
source: 'S',
destination: 'D',
};
assert_eq!(error.to_string(), "S ==> D");
assert!(error.source().is_none());
}

0 comments on commit ef191b1

Please sign in to comment.