From 2644c6fc2c99b63936c3e505340e597b1c1f4fa7 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Thu, 10 Sep 2020 23:11:44 +0100 Subject: unpack: Implement float unpacking. --- unpack_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'unpack_test.c') diff --git a/unpack_test.c b/unpack_test.c index a0eb35e..66d2117 100644 --- a/unpack_test.c +++ b/unpack_test.c @@ -36,6 +36,20 @@ struct test { #include "unpack_test.inc" +TEST(simple0_float, "simple unpack float") +{ + float v[1] = { __LINE__ }; + + CHECK_UNPACK(DATA(0x00, 0x00, 0x00, 0x00), "f", &v); + CHECK_EQUAL("f", v[0], 0.0f); + CHECK_UNPACK(DATA(0x3f, 0x80, 0x00, 0x00), "f", &v); + CHECK_EQUAL("f", v[0], 1.0f); + CHECK_UNPACK(DATA(0x41, 0x00, 0x00, 0x00), "f", &v); + CHECK_EQUAL("f", v[0], 8.0f); + + return true; +} + int main(void) { extern struct test __start_tests, __stop_tests; -- cgit v1.2.3-70-g09d2