Browse Source

merge feature/calculator-subtract to feature/display-menu-calculator and implement calculatorSubtract() in displayMenuCalculator()

remotes/origin/feature/display-menu-calculator
fdai7514 2 years ago
parent
commit
9052852654
  1. 12
      src/calculatorSubtract.c
  2. 11
      src/calculatorSubtract.h
  3. 4
      src/displayMenuCalculator.c
  4. 2
      src/main.c
  5. 121
      tests/test_calculatorSubtract.c

12
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;
}

11
src/calculatorSubtract.h

@ -0,0 +1,11 @@
#ifndef CALCULATORSUBTRACT_H
#define CALCULATORSUBTRACT_H
#include <stdio.h>
#include <stdlib.h>
float calculatorSubtract(float num1, float num2);
#endif // CALCULATORSUBTRACT_H

4
src/displayMenuCalculator.c

@ -2,6 +2,7 @@
#include "calculatorGetUserInput.c" #include "calculatorGetUserInput.c"
#include "calculatorGetUserInputFactorial.c" #include "calculatorGetUserInputFactorial.c"
#include "calculatorAdd.c" #include "calculatorAdd.c"
#include "calculatorSubtract.c"
// Note: // Note:
/* This Function may or may not be implemented in actual program, even if it is merged to the main branch. /* 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 */ 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: case 2:
calculatorGetUserInput(&num1, &num2); calculatorGetUserInput(&num1, &num2);
//NOT YET IMPLEMENTED
answer = calculatorSubtract(num1, num2);
printf("Answer: %f\n", answer);
break; break;
case 3: case 3:

2
src/main.c

@ -3,3 +3,5 @@ int main()
{ {
displayMenuCalculator('c'); //Calculator Function activated with 'c' displayMenuCalculator('c'); //Calculator Function activated with 'c'
} }

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