diff --git a/src/calculatorAdd.c b/src/calculatorAdd.c new file mode 100644 index 0000000..99c892a --- /dev/null +++ b/src/calculatorAdd.c @@ -0,0 +1,12 @@ +#include "calculatorAdd.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 calculatorAdd(float num1,float num2) +{ + return num1+num2; +} + diff --git a/src/calculatorAdd.h b/src/calculatorAdd.h new file mode 100644 index 0000000..412a599 --- /dev/null +++ b/src/calculatorAdd.h @@ -0,0 +1,8 @@ +#ifndef CALCULATORADD_H +#define CALCULATORADD_H + +#include +#include +float calculatorAdd(float num1,float num2); + +#endif // CALCULATORADD_H diff --git a/src/displayMenuCalculator.c b/src/displayMenuCalculator.c index 2638d56..7e59283 100644 --- a/src/displayMenuCalculator.c +++ b/src/displayMenuCalculator.c @@ -1,6 +1,7 @@ #include "displayMenuCalculator.h" #include "calculatorGetUserInput.c" #include "calculatorGetUserInputFactorial.c" +#include "calculatorAdd.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 */ @@ -36,7 +37,8 @@ void displayMenuCalculator(char x) //Displays the correct output, only when x i { //takes user's choice and calls operation-functions accordingly case 1: calculatorGetUserInput(&num1, &num2); - //NOT YET IMPLEMENTED + answer = calculatorAdd(num1, num2); + printf("Answer: %f\n", answer); break; case 2: @@ -64,7 +66,6 @@ void displayMenuCalculator(char x) //Displays the correct output, only when x i return; } } - //NEED TO IMPLEMENT } } diff --git a/tests/test_calculatorAdd.c b/tests/test_calculatorAdd.c new file mode 100644 index 0000000..3e22349 --- /dev/null +++ b/tests/test_calculatorAdd.c @@ -0,0 +1,122 @@ +#ifdef TEST + +#include "unity.h" + +#include "calculatorAdd.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 */ + + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test1_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 26.24; + num2 = 23.22; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test2_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 56.24; + num2 = 233.22; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test3_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 1226.24; + num2 = 323.22; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test4_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 2623.24; + num2 = 2323.22; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test5_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 2435.24; + num2 = 23423.22; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test6_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 4534.24; + num2 = 2221.22; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test7_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 26322.24; + num2 = 2332.222; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test8_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 26132.24; + num2 = 2331122.222; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test9_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 6322.24; + num2 = 21232.2322; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +void test10_calculatorAdd(void) +{ + float num1, num2, actual ,expected; //Arrange + num1 = 1234.456; + num2 = 654.4321; + actual = calculatorAdd(num1, num2); //Act + expected = num1 + num2; + TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert +} + +#endif // TEST