mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-07-28 19:58:55 +00:00
Rename buffer_util.h to binary.h
It will allow to expose more binary util functions not related to buffers. PR #3369 <https://github.com/Genymobile/scrcpy/pull/3369>
This commit is contained in:
parent
136ab8c199
commit
041cdf6cf5
6 changed files with 20 additions and 20 deletions
81
app/tests/test_binary.c
Normal file
81
app/tests/test_binary.c
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "common.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "util/binary.h"
|
||||
|
||||
static void test_write16be(void) {
|
||||
uint16_t val = 0xABCD;
|
||||
uint8_t buf[2];
|
||||
|
||||
sc_write16be(buf, val);
|
||||
|
||||
assert(buf[0] == 0xAB);
|
||||
assert(buf[1] == 0xCD);
|
||||
}
|
||||
|
||||
static void test_write32be(void) {
|
||||
uint32_t val = 0xABCD1234;
|
||||
uint8_t buf[4];
|
||||
|
||||
sc_write32be(buf, val);
|
||||
|
||||
assert(buf[0] == 0xAB);
|
||||
assert(buf[1] == 0xCD);
|
||||
assert(buf[2] == 0x12);
|
||||
assert(buf[3] == 0x34);
|
||||
}
|
||||
|
||||
static void test_write64be(void) {
|
||||
uint64_t val = 0xABCD1234567890EF;
|
||||
uint8_t buf[8];
|
||||
|
||||
sc_write64be(buf, val);
|
||||
|
||||
assert(buf[0] == 0xAB);
|
||||
assert(buf[1] == 0xCD);
|
||||
assert(buf[2] == 0x12);
|
||||
assert(buf[3] == 0x34);
|
||||
assert(buf[4] == 0x56);
|
||||
assert(buf[5] == 0x78);
|
||||
assert(buf[6] == 0x90);
|
||||
assert(buf[7] == 0xEF);
|
||||
}
|
||||
|
||||
static void test_read16be(void) {
|
||||
uint8_t buf[2] = {0xAB, 0xCD};
|
||||
|
||||
uint16_t val = sc_read16be(buf);
|
||||
|
||||
assert(val == 0xABCD);
|
||||
}
|
||||
|
||||
static void test_read32be(void) {
|
||||
uint8_t buf[4] = {0xAB, 0xCD, 0x12, 0x34};
|
||||
|
||||
uint32_t val = sc_read32be(buf);
|
||||
|
||||
assert(val == 0xABCD1234);
|
||||
}
|
||||
|
||||
static void test_read64be(void) {
|
||||
uint8_t buf[8] = {0xAB, 0xCD, 0x12, 0x34,
|
||||
0x56, 0x78, 0x90, 0xEF};
|
||||
|
||||
uint64_t val = sc_read64be(buf);
|
||||
|
||||
assert(val == 0xABCD1234567890EF);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
test_write16be();
|
||||
test_write32be();
|
||||
test_write64be();
|
||||
test_read16be();
|
||||
test_read32be();
|
||||
test_read64be();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue