From 2902e31ff80ca3ec9af38900ef430dbde52ed336 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 3 Nov 2021 12:31:41 +0100 Subject: [PATCH] tests/unittests/tests-fmt: add large scale test for fmt_s32_dfp() --- tests/unittests/tests-fmt/tests-fmt.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unittests/tests-fmt/tests-fmt.c b/tests/unittests/tests-fmt/tests-fmt.c index 75a647b8c7..a11a48e254 100644 --- a/tests/unittests/tests-fmt/tests-fmt.c +++ b/tests/unittests/tests-fmt/tests-fmt.c @@ -738,6 +738,15 @@ static void test_fmt_s32_dfp(void) out[act_len] = '\0'; TEST_ASSERT_EQUAL_STRING("-0.0000001", (char *)out); + val = -1; + fpp = -24; + len = fmt_s32_dfp(NULL, val, fpp); + TEST_ASSERT_EQUAL_INT(3 - fpp, len); + act_len = fmt_s32_dfp(out, val, fpp); + TEST_ASSERT_EQUAL_INT(3 - fpp, act_len); + out[act_len] = '\0'; + TEST_ASSERT_EQUAL_STRING("-0.000000000000000000000001", (char *)out); + /* check that the buffer was not overflowed */ TEST_ASSERT_EQUAL_STRING("z", &out[28]); }