From 06b25d3cfdfa71e219012366703f2f3d10f8f854 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Sat, 12 Sep 2020 00:52:50 +0100 Subject: unpack_test: simple unpack padding test --- unpack_test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/unpack_test.c b/unpack_test.c index 1d7ea4c..28cafdc 100644 --- a/unpack_test.c +++ b/unpack_test.c @@ -64,6 +64,27 @@ TEST(simple0_double, "simple unpack double") return true; } +TEST(simple_padding, "simple unpack padding") +{ + struct { + int i; + unsigned char c; + float f; + } v = { __LINE__, __LINE__ + 1, __LINE__ + 2 }; + + CHECK_UNPACK(DATA(0xff, 0x85, + 0x00, 0x00, 0x00, + 0x16, + 0x00, 0x00, + 0x40, 0x44, 0x58, 0x00), + ">i3xBxxf", &v.i, &v.c, &v.f); + CHECK_EQUAL("d", v.i, -123); + CHECK_EQUAL("d", v.c, 22); + CHECK_EQUAL("f", v.f, 0x1.88bp+1); + + return true; +} + int main(void) { extern struct test __start_tests, __stop_tests; -- cgit v1.2.3-54-g00ecf