diff --git a/build-project.sh b/build-project.sh index f89e14e..75d89ae 100755 --- a/build-project.sh +++ b/build-project.sh @@ -39,7 +39,7 @@ for file in employeeLogin.c createEmployeeAccount.c; do 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 rm main diff --git a/project.yml b/project.yml index b32843f..58b6e73 100644 --- a/project.yml +++ b/project.yml @@ -42,6 +42,14 @@ - src/employeeLogin.* - src/mainMenu.* - src/showGeneralInfoEmployee.* + - src/calculatorAdd.* + - src/calculatorDivide.* + - src/calculatorFactorial.* + - src/calculatorGetUserInput.* + - src/calculatorGetUserInputFactorial.* + - src/calculatorMultiply.* + - src/calculatorSubtract.* + - src/displazMenuCalculator.* :support: - tests/support :libraries: [] diff --git a/src/calculatorAdd.c b/src/calculatorAdd.c new file mode 100644 index 0000000..99c892a --- /dev/null +++ b/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; +} + diff --git a/src/calculatorAdd.h b/src/calculatorAdd.h new file mode 100644 index 0000000..30411f8 --- /dev/null +++ b/src/calculatorAdd.h @@ -0,0 +1,3 @@ +#include +#include +float calculatorAdd(float num1,float num2); diff --git a/src/calculatorDivide.c b/src/calculatorDivide.c new file mode 100644 index 0000000..86e0a5c --- /dev/null +++ b/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; +} + diff --git a/src/calculatorDivide.h b/src/calculatorDivide.h new file mode 100644 index 0000000..2958a72 --- /dev/null +++ b/src/calculatorDivide.h @@ -0,0 +1,3 @@ +#include +#include +float calculatorDivide(float num1, float num2); \ No newline at end of file diff --git a/src/calculatorFactorial.c b/src/calculatorFactorial.c new file mode 100644 index 0000000..e95fd11 --- /dev/null +++ b/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. + } +} + diff --git a/src/calculatorFactorial.h b/src/calculatorFactorial.h new file mode 100644 index 0000000..7d2fafa --- /dev/null +++ b/src/calculatorFactorial.h @@ -0,0 +1,3 @@ +#include +#include +int calculatorFactorial(int num); diff --git a/src/calculatorGetUserInput.c b/src/calculatorGetUserInput.c new file mode 100644 index 0000000..0882efa --- /dev/null +++ b/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); + } +} + + diff --git a/src/calculatorGetUserInput.h b/src/calculatorGetUserInput.h new file mode 100644 index 0000000..96909c3 --- /dev/null +++ b/src/calculatorGetUserInput.h @@ -0,0 +1,5 @@ +#include +#include +void calculatorGetUserInput(float *num1, float *num2); +int allowOnly(); +//const int a = 1; //Just a random constant which has a role in testing diff --git a/src/calculatorGetUserInputFactorial.c b/src/calculatorGetUserInputFactorial.c new file mode 100644 index 0000000..40ab76a --- /dev/null +++ b/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); + } +} + diff --git a/src/calculatorGetUserInputFactorial.h b/src/calculatorGetUserInputFactorial.h new file mode 100644 index 0000000..17eccac --- /dev/null +++ b/src/calculatorGetUserInputFactorial.h @@ -0,0 +1,4 @@ +#include +#include +int allowWhen(); +void calculatorGetUserInputFactorial(int *num); \ No newline at end of file diff --git a/src/calculatorMultiply.c b/src/calculatorMultiply.c new file mode 100644 index 0000000..42e1763 --- /dev/null +++ b/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; +} + diff --git a/src/calculatorMultiply.h b/src/calculatorMultiply.h new file mode 100644 index 0000000..32ecad9 --- /dev/null +++ b/src/calculatorMultiply.h @@ -0,0 +1,3 @@ +#include +#include +float calculatorMultiply(float num1, float num2); \ No newline at end of file diff --git a/src/calculatorSubtract.c b/src/calculatorSubtract.c new file mode 100644 index 0000000..d460458 --- /dev/null +++ b/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; +} + + diff --git a/src/calculatorSubtract.h b/src/calculatorSubtract.h new file mode 100644 index 0000000..6794377 --- /dev/null +++ b/src/calculatorSubtract.h @@ -0,0 +1,4 @@ +#include +#include + +float calculatorSubtract(float num1, float num2); \ No newline at end of file diff --git a/src/displayMenuCalculator.c b/src/displayMenuCalculator.c new file mode 100644 index 0000000..d797a69 --- /dev/null +++ b/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; + } + } + } +} + + + diff --git a/src/displayMenuCalculator.h b/src/displayMenuCalculator.h new file mode 100644 index 0000000..a2ad61d --- /dev/null +++ b/src/displayMenuCalculator.h @@ -0,0 +1,4 @@ +#include +#include +int check(); //int check() is helpful for indirectly testing void displayMenuCalculator() +void displayMenuCalculator(char x); //Displays the correct output, only when x is c. \ No newline at end of file diff --git a/src/employeesCredentialsList.txt b/src/employeesCredentialsList.txt index e8b6ffb..a88ac1a 100644 --- a/src/employeesCredentialsList.txt +++ b/src/employeesCredentialsList.txt @@ -65,3 +65,30 @@ Shivam Schivam007fdlt3781 210960 fdai7207. + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/employeesData.txt b/src/employeesData.txt index 8c5d3ff..bf7405b 100644 --- a/src/employeesData.txt +++ b/src/employeesData.txt @@ -34,3 +34,57 @@ Adress : Fulda,leipzigerstrasse,6 Phone number : +4918756871384 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/error.c b/src/error.c index 1e41a8c..a6a19f3 100644 --- a/src/error.c +++ b/src/error.c @@ -5,23 +5,23 @@ int errorMessage(int errorCode) int returnValue=0; switch(errorCode){ case -1: - //puts("Login not successful."); + // puts("Login not successful."); returnValue = -1; break; case -2: - //puts("Maximum number of attempts reached."); + // puts("Maximum number of attempts reached."); returnValue = -2; break; case -3: - //puts("No menu entry available for this number."); + // puts("No menu entry available for this number."); returnValue = -3; break; 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; break; 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; break; case -6: diff --git a/src/mainMenu.c b/src/mainMenu.c index 0bbf39f..d3cee12 100644 --- a/src/mainMenu.c +++ b/src/mainMenu.c @@ -3,7 +3,7 @@ #include "createEmployeeAccount.h" #include "createCustomer.h" #include "error.h" - +#include "displayMenuCalculator.h" @@ -30,7 +30,7 @@ bool checkIfInteger(char* userInput) bool chooseOption(int choiceInput) { - return !(choiceInput < 1 || choiceInput > 5); + return !(choiceInput < 1 || choiceInput > 6); } @@ -123,7 +123,11 @@ void menuInput() case 4 : getNewEmployeeCredentials(); 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"); 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 ->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\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"); } diff --git a/tests/test_calculatorAdd.c b/tests/test_calculatorAdd.c new file mode 100644 index 0000000..88a58aa --- /dev/null +++ b/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 diff --git a/tests/test_calculatorDivide.c b/tests/test_calculatorDivide.c new file mode 100644 index 0000000..7016ac1 --- /dev/null +++ b/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 +} \ No newline at end of file diff --git a/tests/test_calculatorFactorial.c b/tests/test_calculatorFactorial.c new file mode 100644 index 0000000..8aaf6b0 --- /dev/null +++ b/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 +} diff --git a/tests/test_calculatorGetUserInput.c b/tests/test_calculatorGetUserInput.c new file mode 100644 index 0000000..89bb6f6 --- /dev/null +++ b/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 +} diff --git a/tests/test_calculatorGetUserInputFactorial.c b/tests/test_calculatorGetUserInputFactorial.c new file mode 100644 index 0000000..8d54310 --- /dev/null +++ b/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 diff --git a/tests/test_calculatorMultiply.c b/tests/test_calculatorMultiply.c new file mode 100644 index 0000000..339d3ec --- /dev/null +++ b/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 diff --git a/tests/test_calculatorSubtract.c b/tests/test_calculatorSubtract.c new file mode 100644 index 0000000..323e932 --- /dev/null +++ b/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 diff --git a/tests/test_displayMenuCalculator.c b/tests/test_displayMenuCalculator.c new file mode 100644 index 0000000..5a9fd0c --- /dev/null +++ b/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 diff --git a/tests/test_mainMenu.c b/tests/test_mainMenu.c index 9bbaebe..c97c1b5 100644 --- a/tests/test_mainMenu.c +++ b/tests/test_mainMenu.c @@ -12,6 +12,16 @@ #include "../src/customerMenu.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) { @@ -140,20 +150,20 @@ void test_validChoiceInput(void) /*Arrange*/ - int validInput[4]; + int validInput[6]; bool validInputExpected = true; - for(int i = 0; i < 5; i++) + for(int i = 0; i < 6; i++) { validInput[i] = i + 1; } /*Act and Asssert*/ - for(int i = 0; i < 5; i++) + for(int i = 0; i < 6; i++) { bool validInputResult = chooseOption(validInput[i]); @@ -205,7 +215,7 @@ void test_invalidChoiceInput_secondCase(void) for(int i = 0; i < 100; i++) { - invalidInput[i] = i + 6; + invalidInput[i] = i + 7; } /*Act and Assert*/