Browse Source

refactoring : removed code duplicates for better readability in the unit tests of the function isValidPhoneNumber().

remotes/origin/feature/employees-infos-access
fdai7207 2 years ago
parent
commit
4c49a78378
  1. 25
      tests/test_createEmployeeAccount.c

25
tests/test_createEmployeeAccount.c

@ -230,18 +230,13 @@ void test_validPhoneNumber(void)
{
/*Arrange*/
char* validPhoneNumbers[] = {"+4903584736198","+4912345678912","+4987541024534","+4932145784236","+4987264287139"};
bool validPhoneNumbersResult[5];
bool validPhoneNumbersExpectation = true;
/*Act*/
/*Act and Assert*/
for(int i =0;i<5;i++)
{
validPhoneNumbersResult[i] = isValidPhoneNumber(validPhoneNumbers[i]);
}
/*Assert*/
for(int i=0;i<5;i++)
{
TEST_ASSERT_TRUE(validPhoneNumbersResult[i]);
bool validPhoneNumbersResult = isValidPhoneNumber(validPhoneNumbers[i]);
TEST_ASSERT_EQUAL(validPhoneNumbersExpectation, validPhoneNumbersResult);
}
}
@ -249,19 +244,15 @@ void test_invalidPhoneNumber(void)
{
/*Arrange*/
char* invalidPhoneNumbers[] = {"+490358473619812","+6112345678912","+498754","-4932145784236","123"};
bool invalidPhoneNumbersResult[2];
bool invalidPhoneNumbersExpectation = false;
/*Act*/
/*Act and Assert*/
for(int i =0;i<5;i++)
{
invalidPhoneNumbersResult[i] = isValidPhoneNumber(invalidPhoneNumbers[i]);
bool invalidPhoneNumbersResult = isValidPhoneNumber(invalidPhoneNumbers[i]);
TEST_ASSERT_EQUAL(invalidPhoneNumbersExpectation,invalidPhoneNumbersResult);
}
/*Assert*/
for(int i=0;i<5;i++)
{
TEST_ASSERT_FALSE(invalidPhoneNumbersResult[i]);
}
}
#endif // TEST
Loading…
Cancel
Save