fdai7207
2 years ago
31 changed files with 988 additions and 14 deletions
-
2build-project.sh
-
8project.yml
-
12src/calculatorAdd.c
-
3src/calculatorAdd.h
-
11src/calculatorDivide.c
-
3src/calculatorDivide.h
-
18src/calculatorFactorial.c
-
3src/calculatorFactorial.h
-
26src/calculatorGetUserInput.c
-
5src/calculatorGetUserInput.h
-
22src/calculatorGetUserInputFactorial.c
-
4src/calculatorGetUserInputFactorial.h
-
10src/calculatorMultiply.c
-
3src/calculatorMultiply.h
-
12src/calculatorSubtract.c
-
4src/calculatorSubtract.h
-
88src/displayMenuCalculator.c
-
4src/displayMenuCalculator.h
-
27src/employeesCredentialsList.txt
-
54src/employeesData.txt
-
10src/error.c
-
11src/mainMenu.c
-
122tests/test_calculatorAdd.c
-
117tests/test_calculatorDivide.c
-
79tests/test_calculatorFactorial.c
-
25tests/test_calculatorGetUserInput.c
-
27tests/test_calculatorGetUserInputFactorial.c
-
120tests/test_calculatorMultiply.c
-
121tests/test_calculatorSubtract.c
-
31tests/test_displayMenuCalculator.c
-
18tests/test_mainMenu.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; |
|||
} |
|||
|
@ -0,0 +1,3 @@ |
|||
#include<stdio.h> |
|||
#include<stdlib.h> |
|||
float calculatorAdd(float num1,float num2); |
@ -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; |
|||
} |
|||
|
@ -0,0 +1,3 @@ |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
float calculatorDivide(float num1, float num2); |
@ -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. |
|||
} |
|||
} |
|||
|
@ -0,0 +1,3 @@ |
|||
#include<stdio.h> |
|||
#include<stdlib.h> |
|||
int calculatorFactorial(int num); |
@ -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); |
|||
} |
|||
} |
|||
|
|||
|
@ -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 |
@ -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); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,4 @@ |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
int allowWhen(); |
|||
void calculatorGetUserInputFactorial(int *num); |
@ -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; |
|||
} |
|||
|
@ -0,0 +1,3 @@ |
|||
#include<stdio.h> |
|||
#include<stdlib.h> |
|||
float calculatorMultiply(float num1, float num2); |
@ -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; |
|||
} |
|||
|
|||
|
@ -0,0 +1,4 @@ |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
|
|||
float calculatorSubtract(float num1, float num2); |
@ -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; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
|
@ -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. |
@ -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 |
@ -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 |
|||
} |
@ -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 |
|||
} |
@ -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 |
|||
} |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue