-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
In order to test the error behaviour of a function you need an error struct to compare with. For example:
since ParseIntError
is private, I have to generate one by doing something wrong, like u8::from_str("257")
. This leads to the following test:
let pie_overflow = u8::from_str("257").unwrap_err();
assert_eq!(super::Missions::parse_enc_opt("ascii,256,U+41..U+67",8).unwrap_err(), pie_overflow );
If error types where public I would rather instantiate one and write:
let pie_overflow = ParseIntError {kind: std::num::Overflow};
assert_eq!(super::Missions::parse_enc_opt("ascii,256,U+41..U+67",8).unwrap_err(), pie_overflow );
Maybe there is a reason I do not see why they are private and there is better more idiomatic way of doing error comparison?
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.