Browse Source

merge feature/calculator-divide to feature/display-menu-calculator and implement calculatorDivide() in displayMenuCalculator()

remotes/origin/feature/display-menu-calculator
fdai7514 2 years ago
parent
commit
ba7999b0ce
  1. 11
      src/calculatorDivide.c
  2. 8
      src/calculatorDivide.h
  3. 4
      src/displayMenuCalculator.c
  4. 122
      tests/test_calculatorDivide.c

11
src/calculatorDivide.c

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

8
src/calculatorDivide.h

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

4
src/displayMenuCalculator.c

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

122
tests/test_calculatorDivide.c

@ -0,0 +1,122 @@
#ifdef TEST
#include "unity.h"
#include "calculatorDivide.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_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 26.24;
num2 = 23.22;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test2_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 2236.24;
num2 = 2123.22;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test3_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 623.2;
num2 = 23.22;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test4_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 234.7;
num2 = 124.2;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test5_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 26207.2;
num2 = 278.23;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test6_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 111;
num2 = 21;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test7_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 167;
num2 = 23.22;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test8_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 26124;
num2 = 23022;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test9_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 1234;
num2 = 4321;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test10_calculatorDivide(void)
{
float num1, num2, actual, expected; //Arrange
num1 = 2345;
num2 = 123.7;
expected = num1 / num2;
actual = calculatorDivide(num1, num2); //Act
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
#endif // TEST
Loading…
Cancel
Save