mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-30 11:12:09 +00:00
Add unit test for float decoding
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369>
This commit is contained in:
parent
3848ce86f1
commit
136ab8c199
20
server/src/test/java/com/genymobile/scrcpy/BinaryTest.java
Normal file
20
server/src/test/java/com/genymobile/scrcpy/BinaryTest.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.genymobile.scrcpy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BinaryTest {
|
||||
|
||||
@Test
|
||||
public void testU16FixedPointToFloat() {
|
||||
final float delta = 0.0f; // on these values, there MUST be no rounding error
|
||||
Assert.assertEquals(0.0f, Binary.u16FixedPointToFloat((short) 0), delta);
|
||||
Assert.assertEquals(0.03125f, Binary.u16FixedPointToFloat((short) 0x800), delta);
|
||||
Assert.assertEquals(0.0625f, Binary.u16FixedPointToFloat((short) 0x1000), delta);
|
||||
Assert.assertEquals(0.125f, Binary.u16FixedPointToFloat((short) 0x2000), delta);
|
||||
Assert.assertEquals(0.25f, Binary.u16FixedPointToFloat((short) 0x4000), delta);
|
||||
Assert.assertEquals(0.5f, Binary.u16FixedPointToFloat((short) 0x8000), delta);
|
||||
Assert.assertEquals(0.75f, Binary.u16FixedPointToFloat((short) 0xc000), delta);
|
||||
Assert.assertEquals(1.0f, Binary.u16FixedPointToFloat((short) 0xffff), delta);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user