diff --git a/src/calculatorSubtract.c b/src/calculatorSubtract.c new file mode 100644 index 0000000..d460458 --- /dev/null +++ b/src/calculatorSubtract.c @@ -0,0 +1,12 @@ +#include "calculatorSubtract.h" + +// Note: +/* This Function may or may not be implemented in actual program, even if it is merged to the main branch. + If it is temporarily not included in the main Program, then this has a role in future Development of the Project */ + +float calculatorSubtract (float num1, float num2) +{ + return num1 - num2; +} + + diff --git a/src/calculatorSubtract.h b/src/calculatorSubtract.h new file mode 100644 index 0000000..156eaa9 --- /dev/null +++ b/src/calculatorSubtract.h @@ -0,0 +1,11 @@ +#ifndef CALCULATORSUBTRACT_H +#define CALCULATORSUBTRACT_H + +#include +#include + +float calculatorSubtract(float num1, float num2); + + + +#endif // CALCULATORSUBTRACT_H diff --git a/src/displayMenuCalculator.c b/src/displayMenuCalculator.c index 7e59283..d1c9903 100644 --- a/src/displayMenuCalculator.c +++ b/src/displayMenuCalculator.c @@ -2,6 +2,7 @@ #include "calculatorGetUserInput.c" #include "calculatorGetUserInputFactorial.c" #include "calculatorAdd.c" +#include "calculatorSubtract.c" // Note: /* This Function may or may not be implemented in actual program, even if it is merged to the main branch. If it is temporarily not included in the main Program, then this has a role in future Development of the Project */ @@ -43,7 +44,8 @@ void displayMenuCalculator(char x) //Displays the correct output, only when x i case 2: calculatorGetUserInput(&num1, &num2); - //NOT YET IMPLEMENTED + answer = calculatorSubtract(num1, num2); + printf("Answer: %f\n", answer); break; case 3: diff --git a/src/main.c b/src/main.c index 9a2a175..4ad1bc6 100644 --- a/src/main.c +++ b/src/main.c @@ -3,3 +3,5 @@ int main() { displayMenuCalculator('c'); //Calculator Function activated with 'c' } + + diff --git a/tests/test_calculatorSubtract.c b/tests/test_calculatorSubtract.c new file mode 100644 index 0000000..e898b7b --- /dev/null +++ b/tests/test_calculatorSubtract.c @@ -0,0 +1,121 @@ +#ifdef TEST + +#include "unity.h" + +#include "calculatorSubtract.h" + +// Note: +/* This Function may or may not be implemented in actual program, even if it is merged to the main branch. + If it is temporarily not included in the main Program, then this has a role in future Development of the Project */ + + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + + +void test1_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 123.211; + num2 = 112.21; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test2_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 13.21; + num2 = 112.21; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test3_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 12231.211; + num2 = 1122.21; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test4_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 113453.211; + num2 = 11254.21; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test5_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 12133.211; + num2 = 112.231; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test6_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 1133.201; + num2 = 11221.21; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test7_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 12213.2211; + num2 = 111.21; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test8_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 16213.711; + num2 = 1214.2251; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test9_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 1933.611; + num2 = 1432.21; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test10_calculatorSubtract(void) +{ + float num1, num2, actual, expected; //Arrange + num1 = 1233.811; + num2 = 1121.131; + expected = num1 - num2; + actual = calculatorSubtract(num1, num2); //Act + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +#endif // TEST