Skip to content

Commit

Permalink
Add missing java.lang.Long unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lax1dude committed Dec 3, 2024
1 parent 530b6a5 commit 42fcbb7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/src/test/java/org/teavm/classlib/java/lang/LongTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,35 @@ public void bitsReversed() {
assertEquals(0xF63BA00000000000L, Long.reverse(0x5DC6F));
}

@Test
public void numberOfLeadingZerosComputed() {
assertEquals(0, Long.numberOfLeadingZeros(-1L));
assertEquals(1, Long.numberOfLeadingZeros(0x4000000000000000L));
assertEquals(1, Long.numberOfLeadingZeros(0x4000000000000123L));
assertEquals(1, Long.numberOfLeadingZeros(0x7FFFFFFFFFFFFFFFL));
assertEquals(63, Long.numberOfLeadingZeros(1L));
assertEquals(62, Long.numberOfLeadingZeros(2L));
assertEquals(62, Long.numberOfLeadingZeros(3L));
assertEquals(0, Long.numberOfLeadingZeros(0x8000000000000000L));
assertEquals(0, Long.numberOfLeadingZeros(0x8000000000000123L));
assertEquals(0, Long.numberOfLeadingZeros(0xFFFFFFFFFFFFFFFFL));
assertEquals(64, Long.numberOfLeadingZeros(0L));
}

@Test
public void numberOfTrailingZerosComputed() {
assertEquals(1, Long.numberOfTrailingZeros(0xFFFFFFFFFFFFFFFEL));
assertEquals(1, Long.numberOfTrailingZeros(0x4000000000000002L));
assertEquals(1, Long.numberOfTrailingZeros(0x0000000000000002L));
assertEquals(63, Long.numberOfTrailingZeros(0x8000000000000000L));
assertEquals(62, Long.numberOfTrailingZeros(0x4000000000000000L));
assertEquals(62, Long.numberOfTrailingZeros(0xC000000000000000L));
assertEquals(0, Long.numberOfTrailingZeros(0x0000000000000001L));
assertEquals(0, Long.numberOfTrailingZeros(0x1230000000000003L));
assertEquals(0, Long.numberOfTrailingZeros(0xFFFFFFFFFFFFFFFFL));
assertEquals(64, Long.numberOfTrailingZeros(0L));
}

@Test
public void highestOneBit() {
assertEquals(1L << 63, Long.highestOneBit(-1L));
Expand Down

0 comments on commit 42fcbb7

Please sign in to comment.