From 80b6ee577e033cbe4266ac1af9a6a53b614efda8 Mon Sep 17 00:00:00 2001 From: Leon Wolf Date: Thu, 8 Feb 2024 17:40:19 +0100 Subject: [PATCH] Commit arithmetic Subtraction float --- src/arithmeticSubtraction.c | 5 +++++ src/arithmeticSubtraction.h | 1 + test/test_arithmeticSubtraction.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/arithmeticSubtraction.c b/src/arithmeticSubtraction.c index f8a7eb5..c1bfacd 100644 --- a/src/arithmeticSubtraction.c +++ b/src/arithmeticSubtraction.c @@ -8,3 +8,8 @@ int* subtraction_integer(int a, int b) { *result=a - b; return result; } +float* subtraction_float(float a, float b) { + float* result= malloc(sizeof (float)); + *result=a - b; + return result; +} diff --git a/src/arithmeticSubtraction.h b/src/arithmeticSubtraction.h index 5a36ba5..b7af606 100644 --- a/src/arithmeticSubtraction.h +++ b/src/arithmeticSubtraction.h @@ -3,5 +3,6 @@ #define THEADMIRALS_ARITHMETICSUBTRACTION_H int* subtraction_integer(int a, int b); +float* subtraction_float(float a, float b); #endif //THEADMIRALS_ARITHMETICSUBTRACTION_H diff --git a/test/test_arithmeticSubtraction.c b/test/test_arithmeticSubtraction.c index 26d05c4..633829c 100644 --- a/test/test_arithmeticSubtraction.c +++ b/test/test_arithmeticSubtraction.c @@ -15,4 +15,10 @@ void test_arithmeticSubtraction_subractionoftwonumbers(void) { result = subtraction_integer(14, 7); TEST_ASSERT_EQUAL_INT(expectedResult, *result); } +void test_arithmeticSubtraction_subractionoftwonumberswithfloat(void) { + float expectedResult = 7; + float* result; + result = subtraction_float(14, 7); + TEST_ASSERT_EQUAL_FLOAT(expectedResult, *result); +}