Add unit test for float encoding
PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369>
This commit is contained in:
parent
fd3483c837
commit
1ab6c19486
1 changed files with 13 additions and 0 deletions
|
@ -67,6 +67,17 @@ static void test_read64be(void) {
|
||||||
assert(val == 0xABCD1234567890EF);
|
assert(val == 0xABCD1234567890EF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_float_to_u16fp(void) {
|
||||||
|
assert(sc_float_to_u16fp(0.0f) == 0);
|
||||||
|
assert(sc_float_to_u16fp(0.03125f) == 0x800);
|
||||||
|
assert(sc_float_to_u16fp(0.0625f) == 0x1000);
|
||||||
|
assert(sc_float_to_u16fp(0.125f) == 0x2000);
|
||||||
|
assert(sc_float_to_u16fp(0.25f) == 0x4000);
|
||||||
|
assert(sc_float_to_u16fp(0.5f) == 0x8000);
|
||||||
|
assert(sc_float_to_u16fp(0.75f) == 0xc000);
|
||||||
|
assert(sc_float_to_u16fp(1.0f) == 0xffff);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
(void) argc;
|
(void) argc;
|
||||||
(void) argv;
|
(void) argv;
|
||||||
|
@ -77,5 +88,7 @@ int main(int argc, char *argv[]) {
|
||||||
test_read16be();
|
test_read16be();
|
||||||
test_read32be();
|
test_read32be();
|
||||||
test_read64be();
|
test_read64be();
|
||||||
|
|
||||||
|
test_float_to_u16fp();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue