Browse Source

merge feature/calculator-get-user-input-factorial to feature/display-menu-calculator and implement calculatorGetUserInputFactorial() in displayMenuCalculator()

remotes/origin/feature/display-menu-calculator
fdai7514 2 years ago
parent
commit
b65eedd50b
  1. 20
      src/calculatorGetUserInputFactorial.c
  2. 10
      src/calculatorGetUserInputFactorial.h
  3. 6
      src/displayMenuCalculator.c
  4. 27
      tests/test_calculatorGetUserInputFactorial.c

20
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);
}
}

10
src/calculatorGetUserInputFactorial.h

@ -0,0 +1,10 @@
#ifndef CALCULATORGETUSERINPUTFACTORIAL_H
#define CALCULATORGETUSERINPUTFACTORIAL_H
#include <stdio.h>
#include <stdlib.h>
int allowWhen();
const int utc = 1; //ufc is unitTestConstant, which has a role in unittesting void calculatorGetUserInputFactorial()
void calculatorGetUserInputFactorial(int *num);
#endif // CALCULATORGETUSERINPUTFACTORIAL_H

6
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;

27
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
Loading…
Cancel
Save