Browse Source

refactoring: change variable names in test_calculatorFactorial.c

remotes/origin/feature/calculator-factorial
fdai7514 2 years ago
parent
commit
38cfd6baf1
  1. 5
      src/calculatorFactorial.c
  2. 75
      tests/test_calculatorFactorial.c

5
src/calculatorFactorial.c

@ -1,4 +1,9 @@
#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

75
tests/test_calculatorFactorial.c

@ -4,6 +4,11 @@
#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 */
void setUp(void)
{
}
@ -14,65 +19,65 @@ void tearDown(void)
void test1_calculatorFactorial(void)
{
int p, a, e;
p = 1;
e = 1;
a = calculatorFactorial(p);
TEST_ASSERT_EQUAL_INT(e, a);
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 p, a, e;
p = 0;
e = 1;
a = calculatorFactorial(p);
TEST_ASSERT_EQUAL_INT(e, a);
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 p, a, e;
p = 3;
e = 6;
a = calculatorFactorial(p);
TEST_ASSERT_EQUAL_INT(e, a);
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 p, a, e;
p = 5;
e = 120;
a = calculatorFactorial(p);
TEST_ASSERT_EQUAL_INT(e, a);
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 p, a, e;
p = 8;
e = 40320;
a = calculatorFactorial(p);
TEST_ASSERT_EQUAL_INT(e, a);
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 p, a, e;
p = 11;
e = 39916800;
a = calculatorFactorial(p);
TEST_ASSERT_EQUAL_INT(e, a);
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 p, a, e;
p = 10;
e = 3628800;
a = calculatorFactorial(p);
TEST_ASSERT_EQUAL_INT(e, a);
int num, actual, expected; //Arrange
num = 10;
expected = 3628800;
actual = calculatorFactorial(num); //Act
TEST_ASSERT_EQUAL_INT(expected, actual); //Assert
}

Loading…
Cancel
Save