From feeafc2a743e816034d6b082a8972ed9e9ec1362 Mon Sep 17 00:00:00 2001 From: Dennis Sperzel Date: Mon, 5 Feb 2024 14:01:33 +0100 Subject: [PATCH] testing: addition addition_float base case 0+number=number --- test/test_addition.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test_addition.c b/test/test_addition.c index a6e7e7d..c130001 100644 --- a/test/test_addition.c +++ b/test/test_addition.c @@ -195,4 +195,22 @@ void test_addition_addition_float_0plus0gleich0(void) { TEST_ASSERT_EQUAL_FLOAT(expected, result); } +void test_addition_addition_float_0plusnumbergleichnumber(void) { + float result[5]; + number[0].floating = 45672.56487, number[1].floating = -9531145672.467, number[2].floating = 91357634, number[3].floating = -0.0000000079533144, number[4].floating = 0.0756215698; + float expected[5] = { number[0].floating, number[1].floating, number[2].floating, number[3].floating, number[4].floating }; + + result[0] = addition_float(number[0].floating, (float) 0.0); + result[1] = addition_float((float) 0.0, number[1].floating); + result[2] = addition_float(number[2].floating, (float) 0.0); + result[3] = addition_float((float) 0.0, number[3].floating); + result[4] = addition_float((float) 0.0, number[4].floating); + + TEST_ASSERT_EQUAL_FLOAT(expected[0], result[0]); + TEST_ASSERT_EQUAL_FLOAT(expected[1], result[1]); + TEST_ASSERT_EQUAL_FLOAT(expected[2], result[2]); + TEST_ASSERT_EQUAL_FLOAT(expected[3], result[3]); + TEST_ASSERT_EQUAL_FLOAT(expected[4], result[4]); +} + #endif // TEST