diff --git a/src/multiplication/.gitkeep b/src/multiplication/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/multiplication/multiplication.c b/src/multiplication/multiplication.c new file mode 100644 index 0000000..aee181c --- /dev/null +++ b/src/multiplication/multiplication.c @@ -0,0 +1,4 @@ +int multiply(int a, int b) { + if (a==0||b==0) return 0; + else return a * b; +} diff --git a/src/multiplication/multiplication.h b/src/multiplication/multiplication.h new file mode 100644 index 0000000..295da10 --- /dev/null +++ b/src/multiplication/multiplication.h @@ -0,0 +1,7 @@ +#ifndef multiplication_H +#define multiplication_H + +int multiply(int a, int b); + +#endif + diff --git a/test/multiplication/.gitkeep b/test/multiplication/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/multiplication/test_multiplication.c b/test/multiplication/test_multiplication.c new file mode 100644 index 0000000..e02bb41 --- /dev/null +++ b/test/multiplication/test_multiplication.c @@ -0,0 +1,12 @@ +#include "unity.h" +#include "multiplication.h" + +void setUp(void){} +void tearDown(void){} + +void test_multiplication() { + TEST_ASSERT_EQUAL_INT(6, multiply(2, 3)); + TEST_ASSERT_EQUAL_INT(-6, multiply(2, -3)); + TEST_ASSERT_EQUAL_INT(0, multiply(0, 0)); +} +