diff --git a/src/subtraction/.gitkeep b/src/subtraction/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/subtraction/subtraction.c b/src/subtraction/subtraction.c new file mode 100644 index 0000000..f853998 --- /dev/null +++ b/src/subtraction/subtraction.c @@ -0,0 +1,6 @@ +#include "subtraction.h" +int subtract(int a, int b) { + if (a==0) return b; + if(b==0) return a; + else return a - b; +} diff --git a/src/subtraction/subtraction.h b/src/subtraction/subtraction.h new file mode 100644 index 0000000..0ae67d9 --- /dev/null +++ b/src/subtraction/subtraction.h @@ -0,0 +1,8 @@ +#ifndef subtraction_H +#define subtraction_H + +int subtract(int a, int b); + +#endif + + diff --git a/test/subtraction/.gitkeep b/test/subtraction/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/subtraction/subtraction.c b/test/subtraction/subtraction.c new file mode 100644 index 0000000..d49be5c --- /dev/null +++ b/test/subtraction/subtraction.c @@ -0,0 +1,11 @@ +#include "unity.h" +#include "subtraction.h" +void setUp(){} + +void tearDown(){} + +void test_subtraction() { + TEST_ASSERT_EQUAL_INT(1, subtract(3, 2)); + TEST_ASSERT_EQUAL_INT(5, subtract(2, -3)); + TEST_ASSERT_EQUAL_INT(0, subtract(0, 0)); +}