From: Gerhard Sittig Date: Sat, 22 Jan 2022 12:41:21 +0000 (+0100) Subject: tests: cover u24le and u40le in endianess conversion tests X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;h=1e389eb7daa90aa5651028817ca1ffda8086f5eb;p=libsigrok.git tests: cover u24le and u40le in endianess conversion tests Add a tiny test case which covers the principal operation of the u24le and u40le endianess writers. Expect to see the correct number of bytes and the significant bits. This test does not explicitly check for the absence of adjacent garbage which a naive writer implementation might leave behind outside of the significant bounds. --- diff --git a/tests/conv.c b/tests/conv.c index 5ef0bab1..551365e2 100644 --- a/tests/conv.c +++ b/tests/conv.c @@ -228,6 +228,13 @@ START_TEST(test_endian_write_inc) l = p - &buff[0]; fail_unless(l == 4 * 48 / 8 * sizeof(uint8_t)); fail_unless(memcmp(&buff[0], &buff1234large[0], l) == 0); + + p = &buff[0]; + write_u24le_inc(&p, 0xfe030201); + write_u40le_inc(&p, 0xdcba0807060504ul); + l = p - &buff[0]; + fail_unless(l == 24 / 8 + 40 / 8); + fail_unless(memcmp(&buff[0], &buff1234large[0], l) == 0); } END_TEST