Browse Source

merge feature/calculator-Multiply to feature/display-menu-calculator and implement calculatorMultiply() in displayMenuCalculator()

remotes/origin/feature/display-menu-calculator
fdai7514 2 years ago
parent
commit
4fc681756b
  1. 10
      src/calculatorMultiply.c
  2. 9
      src/calculatorMultiply.h
  3. 4
      src/displayMenuCalculator.c
  4. 1
      src/main.c
  5. 120
      tests/test_calculatorMultiply.c

10
src/calculatorMultiply.c

@ -0,0 +1,10 @@
#include "calculatorMultiply.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 calculatorMultiply(float num1, float num2)
{
return num1 * num2;
}

9
src/calculatorMultiply.h

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

4
src/displayMenuCalculator.c

@ -3,6 +3,7 @@
#include "calculatorGetUserInputFactorial.c" #include "calculatorGetUserInputFactorial.c"
#include "calculatorAdd.c" #include "calculatorAdd.c"
#include "calculatorSubtract.c" #include "calculatorSubtract.c"
#include "calculatorMultiply.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 */
@ -50,7 +51,8 @@ void displayMenuCalculator(char x) //Displays the correct output, only when x i
case 3: case 3:
calculatorGetUserInput(&num1, &num2); calculatorGetUserInput(&num1, &num2);
//NOT YET IMPLEMENTED
answer = calculatorMultiply(num1, num2);
printf("Answer: %f\n", answer);
break; break;
case 4: case 4:

1
src/main.c

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

120
tests/test_calculatorMultiply.c

@ -0,0 +1,120 @@
#ifdef TEST
#include "unity.h"
#include "calculatorMultiply.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_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 26.24;
num2 = 23.22;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test2_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 56.24;
num2 = 233.22;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test3_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 1226.24;
num2 = 323.22;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test4_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 2623.24;
num2 = 2323.22;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test5_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 2435.24;
num2 = 23423.22;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test6_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 4534.24;
num2 = 2221.22;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test7_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 26322.24;
num2 = 2332.222;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test8_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 26132.24;
num2 = 2331122.222;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test9_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 6322.24;
num2 = 21232.2322;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test10_calculatorMultiply(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 1234.456;
num2 = 654.4321;
expected = num1 * num2;
actual = calculatorMultiply(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
#endif // TEST
Loading…
Cancel
Save