Repository navigation
Generate random doubles: net11.0, uniform secure double, real tests - #2407
Open
vladimir-pecanac-main wants to merge 1 commit into
Open
vladimir-pecanac-main wants to merge 1 commit into
vladimir-pecanac-main wants to merge 1 commit into
Conversation
… real tests Fix GetSecureDouble to divide a secure integer by int.MaxValue instead of dividing 1 by it, drop the unused RandomNumberGenerator.Create() call and the redundant casts, use Random.Shared, add the below-upper-bound and wide-range helpers, run Main once with the article's values, and replace the four IsNotNull tests with eight tests that check intervals, spread and the rounding edge cases. MSTest 4.5.3, Microsoft.NET.Test.Sdk 18.12.0, coverlet.collector 10.1.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves numbers-csharp/GenerateRandomDoubles to net11.0 and fixes GetSecureDouble, which divided 1 by a random integer and so returned values piled up next to zero; it now divides a secure integer from RandomNumberGenerator.GetInt32(int.MaxValue) by int.MaxValue, giving evenly spread values in [0, 1). It also switches to Random.Shared, drops the unused RandomNumberGenerator.Create() call and redundant casts, adds GetPseudoDoubleBelowUpperBound and GetPseudoDoubleWithinWideRange, makes Main run once with the article's values instead of a prompt loop that crashed on empty input, and replaces four tests that only checked IsNotNull with eight tests covering the intervals, the spread of the secure double and the rounding and overflow edge cases (MSTest 4.5.3, Microsoft.NET.Test.Sdk 18.12.0, coverlet.collector 10.1.0).