From 2592dd78052f9bec12a6e5703424b63f4291736a Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Fri, 26 Jun 2020 11:44:29 +0200 Subject: [PATCH] unittest/byteorder: add tests for uint32 from/to funcs --- .../tests-core/tests-core-byteorder.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unittests/tests-core/tests-core-byteorder.c b/tests/unittests/tests-core/tests-core-byteorder.c index 2b51f0a514..e7e554a37c 100644 --- a/tests/unittests/tests-core/tests-core-byteorder.c +++ b/tests/unittests/tests-core/tests-core-byteorder.c @@ -88,6 +88,14 @@ static void test_byteorder_bebuftohs(void) TEST_ASSERT_EQUAL_INT(host, byteorder_bebuftohs(bebuf)); } +static void test_byteorder_bebuftohl(void) +{ + static const uint8_t bebuf[4] = { 0xAA, 0xBB, 0xCC, 0xDD}; + static const uint32_t host = 0xAABBCCDD; + + TEST_ASSERT_EQUAL_INT(host, byteorder_bebuftohl(bebuf)); +} + static void test_byteorder_htobebufs(void) { static const uint8_t bebuf[2] = { 0xAA, 0xBB }; @@ -100,6 +108,18 @@ static void test_byteorder_htobebufs(void) TEST_ASSERT_EQUAL_INT(0, memcmp(bebuf, tmp, sizeof(tmp))); } +static void test_byteorder_htobebufl(void) +{ + static const uint8_t bebuf[4] = { 0xAA, 0xBB, 0xCC, 0xDD}; + static const uint32_t host = 0xAABBCCDD; + + uint8_t tmp[4] = {0}; + + byteorder_htobebufl(tmp, host); + + TEST_ASSERT_EQUAL_INT(0, memcmp(bebuf, tmp, sizeof(tmp))); +} + Test *tests_core_byteorder_tests(void) { EMB_UNIT_TESTFIXTURES(fixtures) { @@ -114,6 +134,8 @@ Test *tests_core_byteorder_tests(void) new_TestFixture(test_byteorder_host_to_network_64), new_TestFixture(test_byteorder_bebuftohs), new_TestFixture(test_byteorder_htobebufs), + new_TestFixture(test_byteorder_bebuftohl), + new_TestFixture(test_byteorder_htobebufl), }; EMB_UNIT_TESTCALLER(core_byteorder_tests, NULL, NULL, fixtures);