diff --git a/src/calculatorGetUserInputFactorial.c b/src/calculatorGetUserInputFactorial.c new file mode 100644 index 0000000..0f556e8 --- /dev/null +++ b/src/calculatorGetUserInputFactorial.c @@ -0,0 +1,20 @@ +#include "calculatorGetUserInputFactorial.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 */ + +int allowWhen()// int allowWhen() is helpful for indirectly unittesting void calculatorGetUserInputFactorial() +{ + if(utc == 1) + return 1; +} + +void calculatorGetUserInputFactorial(int *num) +{ + if(allowWhen() == 1)//Only when int allowWhen() returns 1, void calculatorGetUserInputFactorial() will display desired Output + { + printf("num: "); + scanf("%d", num); + } +} + diff --git a/src/calculatorGetUserInputFactorial.h b/src/calculatorGetUserInputFactorial.h new file mode 100644 index 0000000..d8da77c --- /dev/null +++ b/src/calculatorGetUserInputFactorial.h @@ -0,0 +1,10 @@ +#ifndef CALCULATORGETUSERINPUTFACTORIAL_H +#define CALCULATORGETUSERINPUTFACTORIAL_H +#include +#include +int allowWhen(); +const int utc = 1; //ufc is unitTestConstant, which has a role in unittesting void calculatorGetUserInputFactorial() +void calculatorGetUserInputFactorial(int *num); + + +#endif // CALCULATORGETUSERINPUTFACTORIAL_H diff --git a/src/displayMenuCalculator.c b/src/displayMenuCalculator.c index ef34b25..2638d56 100644 --- a/src/displayMenuCalculator.c +++ b/src/displayMenuCalculator.c @@ -1,5 +1,6 @@ #include "displayMenuCalculator.h" #include "calculatorGetUserInput.c" +#include "calculatorGetUserInputFactorial.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 */ @@ -12,11 +13,12 @@ int check() } } - void displayMenuCalculator(char x) //Displays the correct output, only when x is c. { float num1, num2, answer; //Created for storing numbers for addition, subtraction, multiplication and division and the final answer. + int num; //Created specially for calculatorFactorial() int choose; + if(x == 'c') //calculator can be activated by adding 'c' in void displayMenuCalculator() { if(check() == 1) @@ -53,7 +55,7 @@ void displayMenuCalculator(char x) //Displays the correct output, only when x i break; case 5: - //NOT YET IMPLEMENTED + calculatorGetUserInputFactorial(&num); //Created specially for factorial which gets a number from user. //NOT YET IMPLEMENTED break; diff --git a/tests/test_calculatorGetUserInputFactorial.c b/tests/test_calculatorGetUserInputFactorial.c new file mode 100644 index 0000000..b9a2e91 --- /dev/null +++ b/tests/test_calculatorGetUserInputFactorial.c @@ -0,0 +1,27 @@ +#ifdef TEST + +#include "unity.h" + +#include "calculatorGetUserInputFactorial.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 test_calculatorGetUserInputFactorial(void) +{ + int actual, expected; //Arrange + expected = 1; + actual = allowWhen(); //Act + TEST_ASSERT_EQUAL_INT(expected, actual); //Assert +} + +#endif // TEST