From: Gerhard Sittig Date: Sat, 27 Feb 2021 13:35:54 +0000 (+0100) Subject: tests: extend endianess conversion tests to also cover the 48bit writer X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8f87c5284bf05c14e125f0cd6c292417d0decbbe;p=libsigrok.git tests: extend endianess conversion tests to also cover the 48bit writer Cover the recently added writer for 48bit little endian data. Prepare a large bytes pattern buffer that can also serve for future 64bit tests. --- diff --git a/tests/conv.c b/tests/conv.c index ecbe5619..f126c470 100644 --- a/tests/conv.c +++ b/tests/conv.c @@ -34,6 +34,16 @@ static const uint8_t buff8125fb[] = { static const uint8_t buff8125fl[] = { 0x00, 0x00, 0x02, 0x41, 0x00, 0x00, 0x00, 0x00, }; +static const uint8_t buff1234large[] = { + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, +}; START_TEST(test_endian_macro) { @@ -201,6 +211,7 @@ START_TEST(test_endian_write_inc) size_t l; memset(buff, 0, sizeof(buff)); + p = &buff[0]; write_u8_inc(&p, 0x11); write_u16be_inc(&p, 0x2233); @@ -208,6 +219,15 @@ START_TEST(test_endian_write_inc) l = p - &buff[0]; fail_unless(l == sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint32_t)); fail_unless(memcmp(&buff[0], &buff1234[0], l) == 0); + + p = &buff[0]; + write_u48le_inc(&p, 0x060504030201); + write_u48le_inc(&p, 0x0c0b0a090807); + write_u48le_inc(&p, 0x1211100f0e0d); + write_u48le_inc(&p, 0x181716151413); + l = p - &buff[0]; + fail_unless(l == 4 * 48 / 8 * sizeof(uint8_t)); + fail_unless(memcmp(&buff[0], &buff1234large[0], l) == 0); } END_TEST