You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tests currently do not check negative inputs, and would not detect if the library is buggy by accepting too much, e.g. basically never throwing an error. This is because doing so is not really feasible: The "obvious" way to test error scenarios is to assert that the returned error equals some expected error. However, that cannot work, because ErrorKind implements neither Debug nor PartialEq.
Implementing PartialEq is impossible however, because of ParsingFailed { … dyn StdError } and IoError(std::io::Error). Note that [std::io::ErrorKind](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#impl-PartialEq-for-ErrorKind) and [std::num::IntErrorKind](https://doc.rust-lang.org/std/num/enum.IntErrorKind.html#impl-PartialEq-for-IntErrorKind) already implement PartialEq.
I have no good idea how to approach this, only bad ones:
Alternate enum: A new method fn ErrorKind::to_pure(&self) -> PureErrorKind;, which converts the current ErrorKind to a dataless enum PureErrorKind which has PartialEq.
Hardcode the error message in the tests: I hate it. It would work though.
Somehow moving the data to Error, making it easy for the current ErrorKind to implement PartialEq.
The text was updated successfully, but these errors were encountered:
Good observation. I agree that the error should implement Debug, not just for tests, but also to be able to implement std::error::Error. For the tests, errors can still be matched on instead of tested for equality. Something like:
Or maybe we can impose Box<dyn StdError + Send + Sync + PartialEq + 'static> on ParsingFailed? I'd have to check whether the std parsing error implements that.
The tests currently do not check negative inputs, and would not detect if the library is buggy by accepting too much, e.g. basically never throwing an error. This is because doing so is not really feasible: The "obvious" way to test error scenarios is to assert that the returned error equals some expected error. However, that cannot work, because
ErrorKind
implements neitherDebug
norPartialEq
.Implementing
Debug
is an easy fix:Implementing
PartialEq
is impossible however, because ofParsingFailed { … dyn StdError }
andIoError(std::io::Error)
. Note that[std::io::ErrorKind](https://doc.rust-lang.org/std/io/enum.ErrorKind.html#impl-PartialEq-for-ErrorKind)
and[std::num::IntErrorKind](https://doc.rust-lang.org/std/num/enum.IntErrorKind.html#impl-PartialEq-for-IntErrorKind)
already implementPartialEq
.I have no good idea how to approach this, only bad ones:
fn ErrorKind::to_pure(&self) -> PureErrorKind;
, which converts the currentErrorKind
to a datalessenum PureErrorKind
which has PartialEq.Error
, making it easy for the current ErrorKind to implementPartialEq
.The text was updated successfully, but these errors were encountered: