From 38cfd6baf1991d6bd2bde7d5b75c0b11b8d1e03f Mon Sep 17 00:00:00 2001 From: fdai7514 Date: Mon, 6 Feb 2023 20:59:46 +0100 Subject: [PATCH] refactoring: change variable names in test_calculatorFactorial.c --- src/calculatorFactorial.c | 5 +++ tests/test_calculatorFactorial.c | 75 +++++++++++++++++--------------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/calculatorFactorial.c b/src/calculatorFactorial.c index fb1a228..e95fd11 100644 --- a/src/calculatorFactorial.c +++ b/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 diff --git a/tests/test_calculatorFactorial.c b/tests/test_calculatorFactorial.c index 42af4ec..624f9fe 100644 --- a/tests/test_calculatorFactorial.c +++ b/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 }