Browse Source

implementation of unit tests for the function StringLengthCounter.

main
fdai7207 2 years ago
parent
commit
95d5274f54
  1. 1
      src/createEmployeeAccount.c
  2. 3
      src/employeesCredentialsList.txt
  3. 8
      src/employeesData.txt
  4. 24
      src/error.c
  5. 15
      tests/test_createEmployeeAccount.c

1
src/createEmployeeAccount.c

@ -115,7 +115,6 @@ int StringLengthCounter(char* string)
characterCounter++; characterCounter++;
++i; ++i;
} }
string[characterCounter] = '\0';
return characterCounter; return characterCounter;
} }

3
src/employeesCredentialsList.txt

@ -15,6 +15,3 @@ Shivam Schivam007fdlt3781

8
src/employeesData.txt

@ -42,11 +42,3 @@ Phone number : +4918756871384

24
src/error.c

@ -5,51 +5,51 @@ int errorMessage(int errorCode)
int returnValue=0; int returnValue=0;
switch(errorCode){ switch(errorCode){
case -1: case -1:
puts("Login not successful.");
//puts("Login not successful.");
returnValue = -1; returnValue = -1;
break; break;
case -2: case -2:
puts("Maximum number of attempts reached.");
//puts("Maximum number of attempts reached.");
returnValue = -2; returnValue = -2;
break; break;
case -3: case -3:
puts("No menu entry available for this number.");
//puts("No menu entry available for this number.");
returnValue = -3; returnValue = -3;
break; break;
case -4: case -4:
puts("CustomerData.* not found. Make sure that you've created an user account before logging in for the first time. Without users there is no file. Aborting!");
//puts("CustomerData.* not found. Make sure that you've created an user account before logging in for the first time. Without users there is no file. Aborting!");
returnValue = -4; returnValue = -4;
break; break;
case -5: case -5:
puts("You should be at least 18 years old to create a bank account!");
//puts("You should be at least 18 years old to create a bank account!");
returnValue = -5; returnValue = -5;
break; break;
case -6: case -6:
puts("Error when trying to open a file to create a customer account.");
//puts("Error when trying to open a file to create a customer account.");
returnValue = -6; returnValue = -6;
break; break;
case -7: case -7:
puts("Forename too long. (length > 15 characters) Aborting!");
//puts("Forename too long. (length > 15 characters) Aborting!");
returnValue = -7; returnValue = -7;
break; break;
case -8: case -8:
puts("Surname too long. (length > 15 characters) Aborting!");
//puts("Surname too long. (length > 15 characters) Aborting!");
returnValue = -8; returnValue = -8;
break; break;
case -9: case -9:
puts("Password too long. (length > 20 characters) Aboring!");
//puts("Password too long. (length > 20 characters) Aboring!");
returnValue = -9; returnValue = -9;
break; break;
case -10: case -10:
puts("You have entered an invalid character [ä,ö,ü, special characters] for your forename. This is not allowed. Aborting!");
//puts("You have entered an invalid character [ä,ö,ü, special characters] for your forename. This is not allowed. Aborting!");
returnValue = -10; returnValue = -10;
break; break;
case -11: case -11:
puts("You have entered an invalid character [ä,ö,ü, special characters] for your surname. This is not allowed. Aborting!");
//puts("You have entered an invalid character [ä,ö,ü, special characters] for your surname. This is not allowed. Aborting!");
returnValue = -11; returnValue = -11;
break; break;
case -12: case -12:
puts("You entered too many digits.");
//puts("You entered too many digits.");
returnValue = -12; returnValue = -12;
break; break;
default: default:

15
tests/test_createEmployeeAccount.c

@ -302,3 +302,18 @@ void test_invalidPhoneNumber(void)
} }
void test_StringLengthCounter(void)
{
char *strings[] = {"JohnDoe","JaneDoe","FizzBuzz","FooBar","Musterman"};
int expectation[5] = {7,7,8,6,9};
int result[5];
for(int i=0;i<5;i++)
{
result[i] = StringLengthCounter(strings[i]);
}
for(int i = 0;i<5;i++)
{
TEST_ASSERT_EQUAL(expectation[i],result[i]);
}
}
Loading…
Cancel
Save