Browse Source

Extend the test for errorMessage() by adding new test values and assertions.

remotes/origin/development
fdai7057 2 years ago
parent
commit
fc927da8c0
  1. 33
      test/test_Error.c

33
test/test_Error.c

@ -19,6 +19,18 @@ void test_error()
int validErrorCodeUnsuccessfulLogin[bound]; int validErrorCodeUnsuccessfulLogin[bound];
int validErrorCodeMaximumNumberOfAttempts[bound]; int validErrorCodeMaximumNumberOfAttempts[bound];
int validErrorCodeNoMenuEntryForNumber[bound]; int validErrorCodeNoMenuEntryForNumber[bound];
/*new test cases*/
int validErrorCodeNoCustomerDataFile[bound];
int validErrorCodeTooYoung[bound];
int validErrorCodeCreatingFile[bound];
int validErrorCodeForenameTooLong[bound];
int validErrorCodeSurnameTooLong[bound];
int validErrorCodePasswordTooLong[bound];
int validErrorCodeInvalidCharacterForename[bound];
int validErrorCodeInvalidCharacterSurname[bound];
int validErrorCodeTooManyDigits[bound];
for(int i=0;i<bound;++i){ for(int i=0;i<bound;++i){
/*1000 numbers in the range from 1 to 2000 */ /*1000 numbers in the range from 1 to 2000 */
@ -33,7 +45,16 @@ void test_error()
validErrorCodeMaximumNumberOfAttempts[i] = -2; validErrorCodeMaximumNumberOfAttempts[i] = -2;
/*1000 times -3 in array*/ /*1000 times -3 in array*/
validErrorCodeNoMenuEntryForNumber[i] = -3; validErrorCodeNoMenuEntryForNumber[i] = -3;
}
validErrorCodeNoCustomerDataFile[i] = -4;
validErrorCodeTooYoung[i] = -5;
validErrorCodeCreatingFile[i] = -6;
validErrorCodeForenameTooLong[i] = -7;
validErrorCodeSurnameTooLong[i] = -8;
validErrorCodePasswordTooLong[i] = -9;
validErrorCodeInvalidCharacterForename[i] = -10;
validErrorCodeInvalidCharacterSurname[i] = -11;
validErrorCodeTooManyDigits[i] = -12;
}
/*act and assertions for invalid error codes*/ /*act and assertions for invalid error codes*/
for(int i=0;i<bound;++i){ for(int i=0;i<bound;++i){
@ -46,5 +67,15 @@ void test_error()
TEST_ASSERT_EQUAL_INT(-1, errorMessage(validErrorCodeUnsuccessfulLogin[i])); TEST_ASSERT_EQUAL_INT(-1, errorMessage(validErrorCodeUnsuccessfulLogin[i]));
TEST_ASSERT_EQUAL_INT(-2, errorMessage(validErrorCodeMaximumNumberOfAttempts[i])); TEST_ASSERT_EQUAL_INT(-2, errorMessage(validErrorCodeMaximumNumberOfAttempts[i]));
TEST_ASSERT_EQUAL_INT(-3, errorMessage(validErrorCodeNoMenuEntryForNumber[i])); TEST_ASSERT_EQUAL_INT(-3, errorMessage(validErrorCodeNoMenuEntryForNumber[i]));
/*new test cases*/
TEST_ASSERT_EQUAL_INT(-4, errorMessage(validErrorCodeNoCustomerDataFile[i]));
TEST_ASSERT_EQUAL_INT(-5, errorMessage(validErrorCodeTooYoung[i]));
TEST_ASSERT_EQUAL_INT(-6, errorMessage(validErrorCodeCreatingFile[i]));
TEST_ASSERT_EQUAL_INT(-7, errorMessage(validErrorCodeForenameTooLong[i]));
TEST_ASSERT_EQUAL_INT(-8, errorMessage(validErrorCodeSurnameTooLong[i]));
TEST_ASSERT_EQUAL_INT(-9, errorMessage(validErrorCodePasswordTooLong[i]));
TEST_ASSERT_EQUAL_INT(-10, errorMessage(validErrorCodeInvalidCharacterForename[i]));
TEST_ASSERT_EQUAL_INT(-11, errorMessage(validErrorCodeInvalidCharacterSurname[i]));
TEST_ASSERT_EQUAL_INT(-12, errorMessage(validErrorCodeTooManyDigits[i]));
} }
} }
Loading…
Cancel
Save