diff --git a/src/arithmeticSubtraction.c b/src/arithmeticSubtraction.c index c1bfacd..0585677 100644 --- a/src/arithmeticSubtraction.c +++ b/src/arithmeticSubtraction.c @@ -13,3 +13,8 @@ float* subtraction_float(float a, float b) { *result=a - b; return result; } +double* subtraction_double(double a, double b) { + double* result= malloc(sizeof (double)); + *result=a - b; + return result; +} diff --git a/src/arithmeticSubtraction.h b/src/arithmeticSubtraction.h index b7af606..44ea27b 100644 --- a/src/arithmeticSubtraction.h +++ b/src/arithmeticSubtraction.h @@ -4,5 +4,6 @@ int* subtraction_integer(int a, int b); float* subtraction_float(float a, float b); +double* subtraction_double(double a, double b); #endif //THEADMIRALS_ARITHMETICSUBTRACTION_H diff --git a/test/test_arithmeticSubtraction.c b/test/test_arithmeticSubtraction.c index 633829c..007b72b 100644 --- a/test/test_arithmeticSubtraction.c +++ b/test/test_arithmeticSubtraction.c @@ -21,4 +21,11 @@ void test_arithmeticSubtraction_subractionoftwonumberswithfloat(void) { result = subtraction_float(14, 7); TEST_ASSERT_EQUAL_FLOAT(expectedResult, *result); } +void test_arithmeticSubtraction_subractionoftwonumberswithdouble(void) { + double expectedResult = 7; + double* result; + result = subtraction_double(14, 7); + TEST_ASSERT_EQUAL_DOUBLE (expectedResult, *result); +} +