-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl Arbitrary for BigDecimal #122
Comments
If you check out my property tests I'm using proptest to generate Doing something more robust would be nice, but it's pretty low on the todo-list. What's the standard procedure for Arbitrary? Is it add a feature and then just: #[cfg_attr(feature='arbitrary', derive(Arbitrary)]
struct BigDecimal { ... } and as long as
Yeah I've hit that too :-(. |
Arbitrary impls usually don't have anything more configurable by the user. Considering the That said, if you hit it too, TBH I'm not entirely sure why a too big scale leads to memory allocation issues, so this might actually be some bug inside (For full disclosure, I eventually noticed I don't actually need arbitrary decimals, and switched to the finite-length rust_decimal crate since opening this issue, so it went down quite a bit in my priority list too) |
I think the bug is in the implementation of Debug/Display, where the decimal is printed in non-exponential form, even when it'll write exabytes of leading/trailing zeros. I think that's what #121 is addressing but I haven't reviewed it, yet. |
Hey!
I'm trying to fuzz some code that uses BigDecimal, and am hitting the issue that it does not implement
Arbitrary
. Currently, my solution is the following code to generate one:I originally did not have the
% 1000000
, but it resulted in memory allocation failures.What's the recommended way to use BigDecimal from a fuzzer? Relatedly, maybe it'd make sense to add an
arbitrary
feature to BigDecimal, allowing to auto-generate them?Anyway, thank you for BigDecimal! I'm currently stuck on 0.3 because sqlx didn't update probably due to #117 ; but it's really coming in handy to not have to care about floating points and integers too much :)
The text was updated successfully, but these errors were encountered: