]> sigrok.org Git - libsigrok.git/commitdiff
tests: cover u24le and u40le in endianess conversion tests
authorGerhard Sittig <redacted>
Sat, 22 Jan 2022 12:41:21 +0000 (13:41 +0100)
committerGerhard Sittig <redacted>
Sun, 6 Feb 2022 17:53:53 +0000 (18:53 +0100)
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.

tests/conv.c

index 5ef0bab110397914249d85c29fa4e84bc8aa9c74..551365e2a40fc98f62a544c18a3a9752e9cab8fa 100644 (file)
@@ -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