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); +}