-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
server/src/test/java/com/genymobile/scrcpy/BinaryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |