Fix missing nuint casts in BitOperationsTests #120361
Merged
+11
−11
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.
Fixes #[issue_number]
Summary
BitOperationsTestswas missing explicit casts tonuintin several test methods, causing them to inadvertently test the wrong overloads (ulonganduintinstead ofnuint). This resulted in incomplete test coverage for thenuintoverloads ofBitOperationsmethods.Changes
BitOps_RotateRight_nuint (lines 758-767)
The 64-bit test path was calling
BitOperations.RotateRight(value, ...)wherevalueis aulong, which tests theulongoverload instead of thenuintoverload. Fixed by:(nuint)valueparameter to(nuint)in allBitOperations.RotateRight()callsBitOps_LeadingZeroCount_nuint_32 (line 243)
Changed
BitOperations.LeadingZeroCount(n)toBitOperations.LeadingZeroCount((nuint)n)to test thenuintoverload instead of theuintoverload.BitOps_LeadingZeroCount_nuint_64 (line 266)
Changed
BitOperations.LeadingZeroCount(n)toBitOperations.LeadingZeroCount((nuint)n)to test thenuintoverload instead of theulongoverload.Testing
All affected tests now pass and correctly test the
nuintoverloads:BitOps_RotateRight_nuint✅BitOps_LeadingZeroCount_nuint_32✅ (skipped on 64-bit as expected)BitOps_LeadingZeroCount_nuint_64✅ (all 17 test cases passed)The underlying implementation code is correct; only the tests needed fixing to ensure proper coverage.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.