Browse Source

Commit arithmetic Subtraction float

remotes/origin/develop
Leon Wolf 11 months ago
parent
commit
80b6ee577e
  1. 5
      src/arithmeticSubtraction.c
  2. 1
      src/arithmeticSubtraction.h
  3. 6
      test/test_arithmeticSubtraction.c

5
src/arithmeticSubtraction.c

@ -8,3 +8,8 @@ int* subtraction_integer(int a, int b) {
*result=a - b; *result=a - b;
return result; return result;
} }
float* subtraction_float(float a, float b) {
float* result= malloc(sizeof (float));
*result=a - b;
return result;
}

1
src/arithmeticSubtraction.h

@ -3,5 +3,6 @@
#define THEADMIRALS_ARITHMETICSUBTRACTION_H #define THEADMIRALS_ARITHMETICSUBTRACTION_H
int* subtraction_integer(int a, int b); int* subtraction_integer(int a, int b);
float* subtraction_float(float a, float b);
#endif //THEADMIRALS_ARITHMETICSUBTRACTION_H #endif //THEADMIRALS_ARITHMETICSUBTRACTION_H

6
test/test_arithmeticSubtraction.c

@ -15,4 +15,10 @@ void test_arithmeticSubtraction_subractionoftwonumbers(void) {
result = subtraction_integer(14, 7); result = subtraction_integer(14, 7);
TEST_ASSERT_EQUAL_INT(expectedResult, *result); 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);
}
Loading…
Cancel
Save