From 7f0db86eb125159fa7baf761c3d6b759f4b3e29e Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Sun, 5 Feb 2023 07:03:12 +0100 Subject: [PATCH] refactoring : removed redundant code from the unit tests of the isValidEmployee() function. --- src/employeeList.txt | 1 + tests/test_createEmployeeAccount.c | 21 ++++++--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/employeeList.txt b/src/employeeList.txt index ed5a12d..94986be 100644 --- a/src/employeeList.txt +++ b/src/employeeList.txt @@ -9,3 +9,4 @@ Julius Insertcatfdai7057 Mohamed MDfdai6618 Shivam Schivam007fdlt3781 + diff --git a/tests/test_createEmployeeAccount.c b/tests/test_createEmployeeAccount.c index dbd971d..5ba39aa 100644 --- a/tests/test_createEmployeeAccount.c +++ b/tests/test_createEmployeeAccount.c @@ -14,45 +14,36 @@ void tearDown(void) void test_isValidEmployeeID(void) { - + //test case 0 /*Arrange*/ char* validEmployeeId [] = {"Atharva","Can","Haytham","Julius","Mohamed","Shivam","Fizz","Buzz","JohnDoe","Foobar","waz","Objectoriented","INSTITUTIONALISATIOL","Intercommunicational","1234","1.6"}; - int validStringLengths[15]; + int validStringLengths = 20; bool validEmployeeIdExpected = true; - for(int i =0;i<15;i++) - { - validStringLengths[i] = 20; - } - /*Act and Assert*/ for(int i=0; i<15; i++) { - bool validEmployeeIdResult = isValidEmployeeID(validEmployeeId[i],validStringLengths[i]); + bool validEmployeeIdResult = isValidEmployeeID(validEmployeeId[i],validStringLengths); TEST_ASSERT_EQUAL(validEmployeeIdExpected,validEmployeeIdResult); } } void test_isNotValidEmployeeID(void) { - + //test case 1 /*Arrange*/ char* invalidEmployeeId [] = {"Atha rva","Ca n","Geschwindigkeitsbegrenzungen","1234 15","John Doe","fizz Fuzz"}; - int invalidStringLengths[6]; + int invalidStringLengths = 20; bool invalidEmployeeIdExpected = false; - for(int i =0;i<6;i++) - { - invalidStringLengths[i] = 20; - } /*Act and Assert*/ for(int i=0; i<6; i++) { - bool invalidEmployeeIdResult = isValidEmployeeID(invalidEmployeeId[i],invalidStringLengths[i]); + bool invalidEmployeeIdResult = isValidEmployeeID(invalidEmployeeId[i],invalidStringLengths); TEST_ASSERT_EQUAL(invalidEmployeeIdExpected,invalidEmployeeIdResult); }