-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Description
Description
TestBitOperations is missing some casts to nunit and is testing the wrong overload in some cases.
Reproduction Steps
Lines 758 to 767 in 71a7d88
| const ulong value = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul; | |
| Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, | |
| BitOperations.RotateRight(value, 1)); | |
| Assert.Equal(0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul, | |
| BitOperations.RotateRight(value, 2)); | |
| Assert.Equal(0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul, | |
| BitOperations.RotateRight(value, 3)); | |
| Assert.Equal(value, BitOperations.RotateRight(value, int.MinValue)); // % 64 = 0 | |
| Assert.Equal(BitOperations.RotateLeft(value, 63), | |
| BitOperations.RotateRight(value, int.MaxValue)); // % 64 = 63 |
Should be:
const ulong value = 0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul;
Assert.Equal((nuint)0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul,
BitOperation.RotateRight((nuint)value, 1));
Assert.Equal((nuint)0b01010101_01010101_01010101_01010101_01010101_01010101_01010101_01010101ul,
BitOperation.RotateRight((nuint)value, 2));
Assert.Equal((nuint)0b10101010_10101010_10101010_10101010_10101010_10101010_10101010_10101010ul,
BitOperation.RotateRight((nuint)value, 3));
Assert.Equal((nuint)value, BitOperation.RotateRight((nuint)value, int.MinValue)); // % 64 = 0
Assert.Equal(BitOperation.RotateLeft((nuint)value, 63),
BitOperation.RotateRight((nuint)value, int.MaxValue)); // % 64 = 63Line 243 in 71a7d88
| int actual = BitOperations.LeadingZeroCount(n); |
Should be:
int actual = BitOperations.LeadingZeroCount((nuint)n);Line 266 in 71a7d88
| int actual = BitOperations.LeadingZeroCount(n); |
Should be:
int actual = BitOperations.LeadingZeroCount((nuint)n);The code under test is fine once the tests are corrected.
Expected behavior
Tests should be for the correct overload (in this case nunit).
Actual behavior
Tests are calling the wrong overload and coverage is missed.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Copilot