From cd1a80534e62369b93c8f73af8e0582be5e35115 Mon Sep 17 00:00:00 2001 From: Leon Wolf Date: Thu, 8 Feb 2024 17:43:10 +0100 Subject: [PATCH] Commit arithmetic Subtraction double --- src/arithmeticSubtraction.c | 5 +++++ src/arithmeticSubtraction.h | 1 + test/test_arithmeticSubtraction.c | 7 +++++++ 3 files changed, 13 insertions(+) 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); +} +