From 5bf98dc8ec4ade869ed808cf1e7c30213c0cf124 Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Tue, 6 Feb 2024 20:23:32 +0100 Subject: [PATCH] testing: addition reading sign out of double number --- test/test_addition.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_addition.c b/test/test_addition.c index 4190d62..ae4f1e7 100644 --- a/test/test_addition.c +++ b/test/test_addition.c @@ -13,6 +13,11 @@ union { unsigned int integer; } number[6]; +union { + double dnum; + unsigned long lnum; +} numberd[6]; + void setUp(void) { } @@ -279,4 +284,17 @@ void test_addition_addition_float_sumofpositivnumbers(void) TEST_ASSERT_EQUAL_FLOAT(expected[2], result[2]); } +void test_addition_sign_double_numbers(void) +{ + unsigned long result[2]; + unsigned long expected[2] = { 1, 0 }; + numberd[0].dnum = -3004683105640520235, numberd[1].dnum = 0.05313546453135; + + result[0] = sign_double(numberd[0].lnum); + result[1] = sign_double(numberd[1].lnum); + + TEST_ASSERT_EQUAL_UINT64(expected[0], result[0]); + TEST_ASSERT_EQUAL_UINT64(expected[1], result[1]); +} + #endif // TEST