From 1112a6f36506e8fa16f646fa866b69242622db52 Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Wed, 8 Feb 2023 01:07:34 +0100 Subject: [PATCH] refactoring: removed redundant codes from the unit tests of the isValidName() function. --- src/employeesData.txt | 8 -------- tests/test_createEmployeeAccount.c | 28 ++++++++-------------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/employeesData.txt b/src/employeesData.txt index 0169bc0..16f8e9a 100644 --- a/src/employeesData.txt +++ b/src/employeesData.txt @@ -32,11 +32,3 @@ Name : Shivam Last name : Chaudhary Adress : Fulda,leipzigerstrasse,6 Phone number : +4918756871384 - - - - - - - - diff --git a/tests/test_createEmployeeAccount.c b/tests/test_createEmployeeAccount.c index d08f64f..4b66ccf 100644 --- a/tests/test_createEmployeeAccount.c +++ b/tests/test_createEmployeeAccount.c @@ -196,20 +196,14 @@ void test_validName(void) char* validNames[] = {"John","Jane","Fizz","Fooo","Atharva","Cahn","Julius","Haytham","Mohamed","Shivam"}; int minimalLength = 4; - bool validNamesResult[10]; + bool validNamesExpectation = true; - /*Act*/ - - for(int i = 0;i<10;i++) - { - validNamesResult[i] = isValidName(validNames[i],minimalLength); - } - - /*Assert*/ + /*Act and Assert*/ for(int i = 0;i<10;i++) { - TEST_ASSERT_TRUE(validNamesResult[i]); + bool validNamesResult = isValidName(validNames[i],minimalLength); + TEST_ASSERT_EQUAL(validNamesExpectation,validNamesResult); } } @@ -220,20 +214,14 @@ void test_invalidName(void) char* invalidNames[] = {"Jo hn","Jane.","Fizz36","Foo8","Ath,arva","C .a1n","Jul.3ius","H613 aytham","Moh35gta.med","S-+h ivam"}; int minimalLength = 4; - bool invalidNamesResult[10]; + bool invalidNamesExpectation = false; - /*Act*/ - - for(int i = 0;i<10;i++) - { - invalidNamesResult[i] = isValidName(invalidNames[i],minimalLength); - } - - /*Assert*/ + /*Act and Assert*/ for(int i = 0;i<10;i++) { - TEST_ASSERT_FALSE(invalidNamesResult[i]); + bool invalidNamesResult = isValidName(invalidNames[i],minimalLength); + TEST_ASSERT_EQUAL(invalidNamesExpectation,invalidNamesResult); } }