Copilot commented on code in PR #1749:
URL: https://github.com/apache/commons-lang/pull/1749#discussion_r3603757650
##########
src/test/java/org/apache/commons/lang3/BitFieldTest.java:
##########
@@ -141,6 +141,26 @@ void testGetValue() {
assertEquals(BF_ZERO.getValue(0), 0);
}
+ /**
+ * Tests that {@link BitField#getValue(int)} and {@link
BitField#getValue(long)} shift the selected bits right without sign extension
when the field occupies
+ * the top bit of the holder (bit 31 for int, bit 63 for long).
+ */
+ @Test
+ void testGetValueTopBit() {
+ final BitField bit31 = new BitField(0x80000000);
+ assertEquals(bit31.getValue(-1), 1);
+ assertEquals(bit31.getValue(0), 0);
+ final BitField topByte = new BitField(0xFF000000);
+ assertEquals(topByte.getValue(0xFF000000), 255);
+ // The int and long overloads must agree for the same field and holder.
+ assertEquals(topByte.getValue(0xFF000000L), 255L);
Review Comment:
This comment says the int and long overloads must agree, but the following
assertion only compares the long overload to a constant. Consider asserting
equality between the overloads directly so the test matches its stated intent
(and remains robust if the expected constant changes).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]