datafaker icon indicating copy to clipboard operation
datafaker copied to clipboard

Added numberBetween for doubles.

Open bodiam opened this issue 1 year ago • 2 comments

bodiam avatar Oct 19 '24 06:10 bodiam

PR Summary

  • Modification of the 'numberBetween' method The method for generating a random number within a given range has been updated. It is now more flexible and easier to modify in the future.

  • Addition of a new 'numberBetween' method A new version of the method for generating a random number has been created. This one accommodates decimal numbers between set boundaries, extending usability for calculations requiring more precision.

  • Improving the testing structure To secure the efficiency and accuracy of the new method, a special test has been integrated into our regular testing sequence. It safeguards that the generated decimal numbers actually do fall into their prescribed range. This guarantees reliable results for future calculations.

what-the-diff[bot] avatar Oct 19 '24 06:10 what-the-diff[bot]

https://github.com/datafaker-net/datafaker/blob/12bdd2af5d3e0deae8287b916d82769f07e190ed/src/test/java/net/datafaker/FakerTest.java#L211-L215

kingthorin avatar Oct 19 '24 07:10 kingthorin

numberBetweenRepeated

Interesting. What should we do with this? I think what I'm basically asking is: "#{number.number_between '1','10'}", should/could that return 1.5?

bodiam avatar Oct 26 '24 07:10 bodiam

Yes in this case it could be.

kingthorin avatar Oct 26 '24 07:10 kingthorin

Yes in this case it could be.

I agree. I'm just not sure if that's going to break anything. Probably not likely, but not sure. Any suggestions on what to do here? Reject the PR, fix the test, something else?

bodiam avatar Oct 26 '24 11:10 bodiam

I see two options.

  1. Adjust the regex
  2. Make the double method specific instead of numberBetween maybe doubleBetween.

kingthorin avatar Oct 26 '24 12:10 kingthorin

@kingthorin

Adjust the regex

I did.

bodiam avatar Nov 01 '24 14:11 bodiam

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.06%. Comparing base (87a3803) to head (59c4c7c).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1392      +/-   ##
============================================
- Coverage     92.26%   92.06%   -0.20%     
+ Complexity     3166     3157       -9     
============================================
  Files           320      320              
  Lines          6177     6178       +1     
  Branches        592      592              
============================================
- Hits           5699     5688      -11     
- Misses          335      344       +9     
- Partials        143      146       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Nov 01 '24 14:11 codecov[bot]