From f3ee1a219dc5b22da708b105974ab459b0381877 Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Mon, 5 Feb 2024 10:47:16 +0100 Subject: [PATCH] testing: addition read sign out of number --- test/test_addition.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_addition.c b/test/test_addition.c index 89ddcd2..0d97725 100644 --- a/test/test_addition.c +++ b/test/test_addition.c @@ -133,6 +133,24 @@ void test_addition_addition_allunsignedinteger(void) TEST_ASSERT_EQUAL_UINT(expected[4], result[4]); } +void test_addition_signnumber(void) { + unsigned int result[2]; + unsigned int expected[2] = { 0, 1 }; + union { + float f; + unsigned int i; + }a; + + a.f = 1; + result[0] = s(a.i); + + a.f = -1; + result[1] = s(a.i); + + TEST_ASSERT_EQUAL_UINT(expected[0], result[0]); + TEST_ASSERT_EQUAL_UINT(expected[1], result[1]); +} + void test_addition_addition_float_0plus0gleich0(void) { float result; float expected = 0.0;