mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
classlib: fix reverse bytes methods in primitive wrappers (#753)
This commit is contained in:
parent
ba7dcd13b5
commit
e13746a650
|
@ -734,6 +734,6 @@ public class TCharacter extends TObject implements TComparable<TCharacter> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char reverseBytes(char ch) {
|
public static char reverseBytes(char ch) {
|
||||||
return (char) ((ch >> 8) | (ch << 8));
|
return (char) (((ch & 0xFF00) >> 8) | (ch << 8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,6 @@ public class TShort extends TNumber implements TComparable<TShort> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short reverseBytes(short i) {
|
public static short reverseBytes(short i) {
|
||||||
return (short) ((i << 8) | (i >>> 8));
|
return (short) ((i << 8) | ((i & 0xFF00) >> 8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,4 +71,10 @@ public class CharacterTest {
|
||||||
assertEquals('Ü', Character.toUpperCase('ü'));
|
assertEquals('Ü', Character.toUpperCase('ü'));
|
||||||
assertEquals('Ü', Character.toUpperCase('Ü'));
|
assertEquals('Ü', Character.toUpperCase('Ü'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void reverseBytes() {
|
||||||
|
assertEquals((char) 12405, Character.reverseBytes((char) 30000));
|
||||||
|
assertEquals((char) -12150, Character.reverseBytes((char) -30000));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,4 +50,10 @@ public class ShortTest {
|
||||||
public void bytes() {
|
public void bytes() {
|
||||||
assertEquals(2, Short.BYTES);
|
assertEquals(2, Short.BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void reverseBytes() {
|
||||||
|
assertEquals((short) 12405, Short.reverseBytes((short) 30000));
|
||||||
|
assertEquals((short) -12150, Short.reverseBytes((short) -30000));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user