Closed
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?