Browse Source

Resolve merge conflicts.

remotes/origin/Alpha
fdai7207 2 years ago
parent
commit
859788e279
  1. 2
      build-project.sh
  2. 8
      project.yml
  3. 12
      src/calculatorAdd.c
  4. 3
      src/calculatorAdd.h
  5. 11
      src/calculatorDivide.c
  6. 3
      src/calculatorDivide.h
  7. 18
      src/calculatorFactorial.c
  8. 3
      src/calculatorFactorial.h
  9. 26
      src/calculatorGetUserInput.c
  10. 5
      src/calculatorGetUserInput.h
  11. 22
      src/calculatorGetUserInputFactorial.c
  12. 4
      src/calculatorGetUserInputFactorial.h
  13. 10
      src/calculatorMultiply.c
  14. 3
      src/calculatorMultiply.h
  15. 12
      src/calculatorSubtract.c
  16. 4
      src/calculatorSubtract.h
  17. 88
      src/displayMenuCalculator.c
  18. 4
      src/displayMenuCalculator.h
  19. 27
      src/employeesCredentialsList.txt
  20. 54
      src/employeesData.txt
  21. 10
      src/error.c
  22. 13
      src/mainMenu.c
  23. 122
      tests/test_calculatorAdd.c
  24. 117
      tests/test_calculatorDivide.c
  25. 79
      tests/test_calculatorFactorial.c
  26. 25
      tests/test_calculatorGetUserInput.c
  27. 27
      tests/test_calculatorGetUserInputFactorial.c
  28. 120
      tests/test_calculatorMultiply.c
  29. 121
      tests/test_calculatorSubtract.c
  30. 31
      tests/test_displayMenuCalculator.c
  31. 18
      tests/test_mainMenu.c

2
build-project.sh

@ -39,7 +39,7 @@ for file in employeeLogin.c createEmployeeAccount.c; do
done done
gcc mainMenu.c error.c createEmployeeAccount.c showGeneralInfoEmployee.c employeeLogin.c createCustomer.c helperFunctions.c loginCustomer.c customerMenu.c main.c -o main
gcc mainMenu.c error.c createEmployeeAccount.c showGeneralInfoEmployee.c employeeLogin.c createCustomer.c helperFunctions.c loginCustomer.c customerMenu.c main.c calculatorAdd.c calculatorDivide.c calculatorFactorial.c calculatorGetUserInput.c calculatorGetUserInputFactorial.c calculatorMultiply.c calculatorSubtract.c displayMenuCalculator.c -o main
./main ./main
rm main rm main

8
project.yml

@ -42,6 +42,14 @@
- src/employeeLogin.* - src/employeeLogin.*
- src/mainMenu.* - src/mainMenu.*
- src/showGeneralInfoEmployee.* - src/showGeneralInfoEmployee.*
- src/calculatorAdd.*
- src/calculatorDivide.*
- src/calculatorFactorial.*
- src/calculatorGetUserInput.*
- src/calculatorGetUserInputFactorial.*
- src/calculatorMultiply.*
- src/calculatorSubtract.*
- src/displazMenuCalculator.*
:support: :support:
- tests/support - tests/support
:libraries: [] :libraries: []

12
src/calculatorAdd.c

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

3
src/calculatorAdd.h

@ -0,0 +1,3 @@
#include<stdio.h>
#include<stdlib.h>
float calculatorAdd(float num1,float num2);

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

3
src/calculatorDivide.h

@ -0,0 +1,3 @@
#include <stdio.h>
#include <stdlib.h>
float calculatorDivide(float num1, float num2);

18
src/calculatorFactorial.c

@ -0,0 +1,18 @@
#include "calculatorFactorial.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 calculatorFactorial(int num) //implement recursion. The function calls itself so many times, till the breaking condition is fulfilled.
{
if (num == 0) //breaking condition
{
return 1;
}
else
{
return num * calculatorFactorial(num - 1); //If its not breaking condition, then multiply the number with the same function implemented on the previous number. Eventually it will reach breaking condition.
}
}

3
src/calculatorFactorial.h

@ -0,0 +1,3 @@
#include<stdio.h>
#include<stdlib.h>
int calculatorFactorial(int num);

26
src/calculatorGetUserInput.c

@ -0,0 +1,26 @@
#include "calculatorGetUserInput.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 allowOnly() //int allowOnly() is helpful for indirectly testing void calculatorGetUserInput().
{
const int a = 1;
if(a == 1) //Just a random constant which has a role in testing
{
return 1;
}
}
void calculatorGetUserInput(float *num1, float *num2)
{
if (allowOnly() == 1) //only if int allowOnly() returns 1, void calculatorGetUserInput will display the desired output.
{
printf("number1: ");
scanf("%f", num1);
printf("number2: ");
scanf("%f", num2);
}
}

5
src/calculatorGetUserInput.h

@ -0,0 +1,5 @@
#include<stdio.h>
#include<stdlib.h>
void calculatorGetUserInput(float *num1, float *num2);
int allowOnly();
//const int a = 1; //Just a random constant which has a role in testing

22
src/calculatorGetUserInputFactorial.c

@ -0,0 +1,22 @@
#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()
{
//ufc is unitTestConstant, which has a role in unittesting void calculatorGetUserInputFactorial()
const int utc = 1;
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);
}
}

4
src/calculatorGetUserInputFactorial.h

@ -0,0 +1,4 @@
#include <stdio.h>
#include <stdlib.h>
int allowWhen();
void calculatorGetUserInputFactorial(int *num);

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

3
src/calculatorMultiply.h

@ -0,0 +1,3 @@
#include<stdio.h>
#include<stdlib.h>
float calculatorMultiply(float num1, float num2);

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

4
src/calculatorSubtract.h

@ -0,0 +1,4 @@
#include <stdio.h>
#include <stdlib.h>
float calculatorSubtract(float num1, float num2);

88
src/displayMenuCalculator.c

@ -0,0 +1,88 @@
#include "displayMenuCalculator.h"
#include "calculatorGetUserInput.h"
#include "calculatorGetUserInputFactorial.h"
#include "calculatorAdd.h"
#include "calculatorSubtract.h"
#include "calculatorMultiply.h"
#include "calculatorDivide.h"
#include "calculatorFactorial.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 operation1 = 1;
int operation2 = 2;
int operation3 = 3;
int operation4 = 4;
int operation5 = 5;
int check()
{
const int rConst = 1; // RandomConstant created for indirectly testing void displayMenuCalculator()
if(rConst == 1)// RandomConstant created for indirectly testing void displayMenuCalculator()
{
return 1;
}
}
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)
{ //The Main Menu of the calculator
printf(" %d. Add\n", operation1);
printf(" %d. Subtract\n", operation2);
printf(" %d. Multiply\n", operation3);
printf(" %d. Divide\n", operation4);
printf(" %d. Factorial\n", operation5);
printf("Enter your choice: "); // Takes the choice of operations from the user
scanf("%d", &choose); // Saves the choice
switch (choose)
{ //takes user's choice and calls operation-functions accordingly
case 1:
calculatorGetUserInput(&num1, &num2);
answer = calculatorAdd(num1, num2);
printf("Answer: %f\n", answer);
break;
case 2:
calculatorGetUserInput(&num1, &num2);
answer = calculatorSubtract(num1, num2);
printf("Answer: %f\n", answer);
break;
case 3:
calculatorGetUserInput(&num1, &num2);
answer = calculatorMultiply(num1, num2);
printf("Answer: %f\n", answer);
break;
case 4:
calculatorGetUserInput(&num1, &num2);
answer = calculatorDivide(num1, num2);
printf("Answer: %f\n", answer);
break;
case 5:
calculatorGetUserInputFactorial(&num); //Created specially for factorial which gets a number from user.
answer = calculatorFactorial(num);
printf("Answer: %f\n", answer);
break;
default:
printf("Invalid choice\n");
return;
}
}
}
}

4
src/displayMenuCalculator.h

@ -0,0 +1,4 @@
#include<stdio.h>
#include<stdlib.h>
int check(); //int check() is helpful for indirectly testing void displayMenuCalculator()
void displayMenuCalculator(char x); //Displays the correct output, only when x is c.

27
src/employeesCredentialsList.txt

@ -65,3 +65,30 @@ Shivam Schivam007fdlt3781
210960 fdai7207. 210960 fdai7207.

54
src/employeesData.txt

@ -34,3 +34,57 @@ Adress : Fulda,leipzigerstrasse,6
Phone number : +4918756871384 Phone number : +4918756871384

10
src/error.c

@ -5,23 +5,23 @@ int errorMessage(int errorCode)
int returnValue=0; int returnValue=0;
switch(errorCode){ switch(errorCode){
case -1: case -1:
//puts("Login not successful.");
// puts("Login not successful.");
returnValue = -1; returnValue = -1;
break; break;
case -2: case -2:
//puts("Maximum number of attempts reached.");
// puts("Maximum number of attempts reached.");
returnValue = -2; returnValue = -2;
break; break;
case -3: case -3:
//puts("No menu entry available for this number.");
// puts("No menu entry available for this number.");
returnValue = -3; returnValue = -3;
break; break;
case -4: case -4:
//puts("CustomerData.* not found. Make sure that you've created an user account before logging in for the first time. Without users there is no file. Aborting!");
// puts("CustomerData.* not found. Make sure that you've created an user account before logging in for the first time. Without users there is no file. Aborting!");
returnValue = -4; returnValue = -4;
break; break;
case -5: case -5:
//puts("You should be at least 18 years old to create a bank account!");
// puts("You should be at least 18 years old to create a bank account!");
returnValue = -5; returnValue = -5;
break; break;
case -6: case -6:

13
src/mainMenu.c

@ -3,7 +3,7 @@
#include "createEmployeeAccount.h" #include "createEmployeeAccount.h"
#include "createCustomer.h" #include "createCustomer.h"
#include "error.h" #include "error.h"
#include "displayMenuCalculator.h"
@ -30,7 +30,7 @@ bool checkIfInteger(char* userInput)
bool chooseOption(int choiceInput) bool chooseOption(int choiceInput)
{ {
return !(choiceInput < 1 || choiceInput > 5);
return !(choiceInput < 1 || choiceInput > 6);
} }
@ -123,7 +123,11 @@ void menuInput()
case 4 : getNewEmployeeCredentials(); case 4 : getNewEmployeeCredentials();
break; break;
case 5 : printf("\e[1;1H\e[2J");
case 5 : displayMenuCalculator('c');
break;
case 6 : printf("\e[1;1H\e[2J");
printf("\nsee you next time !\n\n"); printf("\nsee you next time !\n\n");
break; break;
} }
@ -139,7 +143,8 @@ void showMenu()
printf("\n\n\t\t\t\t\t\t ->Register as a new costumer."); printf("\n\n\t\t\t\t\t\t ->Register as a new costumer.");
printf("\n\n\t\t\t\t\t\t ->Login as an Employee."); printf("\n\n\t\t\t\t\t\t ->Login as an Employee.");
printf("\n\n\t\t\t\t\t\t ->Register as an Employee."); printf("\n\n\t\t\t\t\t\t ->Register as an Employee.");
printf("\n\n\t\t\t\t\t\t\t\t ->Exit.\n");
printf("\n\n\t\t\t\t\t\t ->Calculator");
printf("\n\n\t\t\t\t\t\t\t\t ->Exit.\n");
printf("\n\n\n\n\n Selection :\n"); printf("\n\n\n\n\n Selection :\n");
} }

122
tests/test_calculatorAdd.c

@ -0,0 +1,122 @@
#ifdef TEST
#include "unity.h"
#include "../src/calculatorAdd.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 test1_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 26.24;
num2 = 23.22;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test2_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 56.24;
num2 = 233.22;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test3_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 1226.24;
num2 = 323.22;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test4_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 2623.24;
num2 = 2323.22;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test5_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 2435.24;
num2 = 23423.22;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test6_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 4534.24;
num2 = 2221.22;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test7_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 26322.24;
num2 = 2332.222;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test8_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 26132.24;
num2 = 2331122.222;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test9_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 6322.24;
num2 = 21232.2322;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
void test10_calculatorAdd(void)
{
float num1, num2, actual ,expected; //Arrange
num1 = 1234.456;
num2 = 654.4321;
actual = calculatorAdd(num1, num2); //Act
expected = num1 + num2;
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert
}
#endif // TEST

117
tests/test_calculatorDivide.c

@ -0,0 +1,117 @@
#include "unity.h"
#include "../src/calculatorDivide.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 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
}

79
tests/test_calculatorFactorial.c

@ -0,0 +1,79 @@
#include "unity.h"
#include "../src/calculatorFactorial.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 test1_calculatorFactorial(void)
{
int num, actual, expected; //Arrange
num = 1;
expected = 1;
actual = calculatorFactorial(num); //Act
TEST_ASSERT_EQUAL_INT(expected, actual); //Assert
}
void test2_calculatorFactorial(void)
{
int num, actual, expected; //Arrange
num = 0;
expected = 1;
actual = calculatorFactorial(num); //Act
TEST_ASSERT_EQUAL_INT(expected, actual); //Assert
}
void test3_calculatorFactorial(void)
{
int num, actual, expected; //Arrange
num = 3;
expected = 6;
actual = calculatorFactorial(num); //Act
TEST_ASSERT_EQUAL_INT(expected, actual); //Assert
}
void test4_calculatorFactorial(void)
{
int num, actual, expected; //Arrange
num = 5;
expected = 120;
actual = calculatorFactorial(num); //Act
TEST_ASSERT_EQUAL_INT(expected, actual); //Assert
}
void test5_calculatorFactorial(void)
{
int num, actual, expected; //Arrange
num = 8;
expected = 40320;
actual = calculatorFactorial(num); //Act
TEST_ASSERT_EQUAL_INT(expected, actual); //Assert
}
void test6_calculatorFactorial(void)
{
int num, actual, expected; //Arrange
num = 11;
expected = 39916800;
actual = calculatorFactorial(num); //Act
TEST_ASSERT_EQUAL_INT(expected, actual); //Assert
}
void test7_calculatorFactorial(void)
{
int num, actual, expected; //Arrange
num = 10;
expected = 3628800;
actual = calculatorFactorial(num); //Act
TEST_ASSERT_EQUAL_INT(expected, actual); //Assert
}

25
tests/test_calculatorGetUserInput.c

@ -0,0 +1,25 @@
#include "unity.h"
#include "../src/calculatorGetUserInput.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_calculatorGetUserInput_NeedToImplement(void)
{
int actual, expected; //Arrange
expected = 1;
actual = allowOnly(); //Act
TEST_ASSERT_EQUAL_INT(expected, actual);//Assert
}

27
tests/test_calculatorGetUserInputFactorial.c

@ -0,0 +1,27 @@
#ifdef TEST
#include "unity.h"
#include "../src/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

120
tests/test_calculatorMultiply.c

@ -0,0 +1,120 @@
#ifdef TEST
#include "unity.h"
#include "../src/calculatorMultiply.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 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

121
tests/test_calculatorSubtract.c

@ -0,0 +1,121 @@
#ifdef TEST
#include "unity.h"
#include "../src/calculatorSubtract.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 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

31
tests/test_displayMenuCalculator.c

@ -0,0 +1,31 @@
#ifdef TEST
#include "unity.h"
#include "../src/displayMenuCalculator.c"
#include "../src/calculatorAdd.c"
#include "../src/calculatorDivide.c"
#include "../src/calculatorFactorial.c"
#include "../src/calculatorGetUserInput.c"
#include "../src/calculatorGetUserInputFactorial.c"
#include "../src/calculatorMultiply.c"
#include "../src/calculatorSubtract.c"
void setUp(void)
{
}
void tearDown(void)
{
}
void test_displayMenuCalculator(void)
{
int expected, actual; //Arrange
expected = 1;
actual = check(); //Act
TEST_ASSERT_EQUAL_INT(expected, actual);//Assert
}
#endif // TEST

18
tests/test_mainMenu.c

@ -12,6 +12,16 @@
#include "../src/customerMenu.c" #include "../src/customerMenu.c"
#include "../src/showGeneralInfoEmployee.c" #include "../src/showGeneralInfoEmployee.c"
#include "../src/calculatorAdd.c"
#include "../src/calculatorDivide.c"
#include "../src/calculatorFactorial.c"
#include "../src/calculatorGetUserInput.c"
#include "../src/calculatorGetUserInputFactorial.c"
#include "../src/calculatorMultiply.c"
#include "../src/calculatorSubtract.c"
#include "../src/displayMenuCalculator.c"
void setUp(void) void setUp(void)
{ {
@ -140,20 +150,20 @@ void test_validChoiceInput(void)
/*Arrange*/ /*Arrange*/
int validInput[4];
int validInput[6];
bool validInputExpected = true; bool validInputExpected = true;
for(int i = 0; i < 5; i++)
for(int i = 0; i < 6; i++)
{ {
validInput[i] = i + 1; validInput[i] = i + 1;
} }
/*Act and Asssert*/ /*Act and Asssert*/
for(int i = 0; i < 5; i++)
for(int i = 0; i < 6; i++)
{ {
bool validInputResult = chooseOption(validInput[i]); bool validInputResult = chooseOption(validInput[i]);
@ -205,7 +215,7 @@ void test_invalidChoiceInput_secondCase(void)
for(int i = 0; i < 100; i++) for(int i = 0; i < 100; i++)
{ {
invalidInput[i] = i + 6;
invalidInput[i] = i + 7;
} }
/*Act and Assert*/ /*Act and Assert*/

Loading…
Cancel
Save