|
|
@ -2,9 +2,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "util/buffer_util.h"
|
|
|
|
#include "util/binary.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void test_buffer_write16be(void) {
|
|
|
|
static void test_write16be(void) {
|
|
|
|
uint16_t val = 0xABCD;
|
|
|
|
uint16_t val = 0xABCD;
|
|
|
|
uint8_t buf[2];
|
|
|
|
uint8_t buf[2];
|
|
|
|
|
|
|
|
|
|
|
@ -14,7 +14,7 @@ static void test_buffer_write16be(void) {
|
|
|
|
assert(buf[1] == 0xCD);
|
|
|
|
assert(buf[1] == 0xCD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_buffer_write32be(void) {
|
|
|
|
static void test_write32be(void) {
|
|
|
|
uint32_t val = 0xABCD1234;
|
|
|
|
uint32_t val = 0xABCD1234;
|
|
|
|
uint8_t buf[4];
|
|
|
|
uint8_t buf[4];
|
|
|
|
|
|
|
|
|
|
|
@ -26,7 +26,7 @@ static void test_buffer_write32be(void) {
|
|
|
|
assert(buf[3] == 0x34);
|
|
|
|
assert(buf[3] == 0x34);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_buffer_write64be(void) {
|
|
|
|
static void test_write64be(void) {
|
|
|
|
uint64_t val = 0xABCD1234567890EF;
|
|
|
|
uint64_t val = 0xABCD1234567890EF;
|
|
|
|
uint8_t buf[8];
|
|
|
|
uint8_t buf[8];
|
|
|
|
|
|
|
|
|
|
|
@ -42,7 +42,7 @@ static void test_buffer_write64be(void) {
|
|
|
|
assert(buf[7] == 0xEF);
|
|
|
|
assert(buf[7] == 0xEF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_buffer_read16be(void) {
|
|
|
|
static void test_read16be(void) {
|
|
|
|
uint8_t buf[2] = {0xAB, 0xCD};
|
|
|
|
uint8_t buf[2] = {0xAB, 0xCD};
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t val = sc_read16be(buf);
|
|
|
|
uint16_t val = sc_read16be(buf);
|
|
|
@ -50,7 +50,7 @@ static void test_buffer_read16be(void) {
|
|
|
|
assert(val == 0xABCD);
|
|
|
|
assert(val == 0xABCD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_buffer_read32be(void) {
|
|
|
|
static void test_read32be(void) {
|
|
|
|
uint8_t buf[4] = {0xAB, 0xCD, 0x12, 0x34};
|
|
|
|
uint8_t buf[4] = {0xAB, 0xCD, 0x12, 0x34};
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t val = sc_read32be(buf);
|
|
|
|
uint32_t val = sc_read32be(buf);
|
|
|
@ -58,7 +58,7 @@ static void test_buffer_read32be(void) {
|
|
|
|
assert(val == 0xABCD1234);
|
|
|
|
assert(val == 0xABCD1234);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_buffer_read64be(void) {
|
|
|
|
static void test_read64be(void) {
|
|
|
|
uint8_t buf[8] = {0xAB, 0xCD, 0x12, 0x34,
|
|
|
|
uint8_t buf[8] = {0xAB, 0xCD, 0x12, 0x34,
|
|
|
|
0x56, 0x78, 0x90, 0xEF};
|
|
|
|
0x56, 0x78, 0x90, 0xEF};
|
|
|
|
|
|
|
|
|
|
|
@ -71,11 +71,11 @@ int main(int argc, char *argv[]) {
|
|
|
|
(void) argc;
|
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
|
|
|
(void) argv;
|
|
|
|
|
|
|
|
|
|
|
|
test_buffer_write16be();
|
|
|
|
test_write16be();
|
|
|
|
test_buffer_write32be();
|
|
|
|
test_write32be();
|
|
|
|
test_buffer_write64be();
|
|
|
|
test_write64be();
|
|
|
|
test_buffer_read16be();
|
|
|
|
test_read16be();
|
|
|
|
test_buffer_read32be();
|
|
|
|
test_read32be();
|
|
|
|
test_buffer_read64be();
|
|
|
|
test_read64be();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|