@ -12,29 +12,39 @@ void test_error()
/*arrange*/
srand ( time ( 0 ) ) ;
int bound = 1000 ;
int val1 , val2 , val3 , val4 , val5 , val6 , val7 , val8 , val9 , val10 ;
int invalidErrorCodes_1 [ bound ] ;
int invalidErrorCodesLarge_2 [ bound ] ;
int invalidErrorCodesLargest_3 [ bound ] ;
/*act*/
val1 = rand ( ) % 1000 + 1 ;
val2 = rand ( ) % 1000 + 1 ;
val3 = rand ( ) % 1000 + 1 ;
val4 = rand ( ) % 1000 + 1 ;
val5 = rand ( ) % 1000 + 1 ;
val6 = rand ( ) % 1000 + 1 ;
val7 = rand ( ) % 1000 + 1 ;
val8 = rand ( ) % 1000 + 1 ;
val9 = rand ( ) % 1000 + 1 ;
val10 = rand ( ) % 1000 + 1 ;
int validErrorCodeUnsuccessfulLogin [ bound ] ;
int validErrorCodeMaximumNumberOfAttempts [ bound ] ;
int validErrorCodeNoMenuEntryForNumber [ bound ] ;
/*assertions*/
TEST_ASSERT_EQUAL_INT ( 0 , error ( val1 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val2 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val3 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val4 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val5 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val6 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val7 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val8 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val9 ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( val10 ) ) ;
for ( int i = 0 ; i < bound ; + + i ) {
/*1000 numbers in the range from 1 to 2000 */
invalidErrorCodes_1 [ i ] = rand ( ) % 2000 + 1 ;
/*1000 numbers in the range from 1000.000 to 100.999.999*/
invalidErrorCodesLarge_2 [ i ] = ( rand ( ) % 100000000 ) + 1000000 ;
/*1000 numbers in the range from 1.000.000.000 to 2.000.000.000*/
invalidErrorCodesLargest_3 [ i ] = ( rand ( ) % 1000000001 ) + 1000000000 ;
/*1000 times -1 in array*/
validErrorCodeUnsuccessfulLogin [ i ] = - 1 ;
/*1000 times -2 in array*/
validErrorCodeMaximumNumberOfAttempts [ i ] = - 2 ;
/*1000 times -3 in array*/
validErrorCodeNoMenuEntryForNumber [ i ] = - 3 ;
}
/*act and assertions for invalid error codes*/
for ( int i = 0 ; i < bound ; + + i ) {
TEST_ASSERT_EQUAL_INT ( 0 , error ( invalidErrorCodes_1 [ i ] ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( invalidErrorCodesLarge_2 [ i ] ) ) ;
TEST_ASSERT_EQUAL_INT ( 0 , error ( invalidErrorCodesLargest_3 [ i ] ) ) ;
}
/*act and assertions for valid error codes*/
for ( int i = 0 ; i < bound ; + + i ) {
TEST_ASSERT_EQUAL_INT ( - 1 , error ( validErrorCodeUnsuccessfulLogin [ i ] ) ) ;
TEST_ASSERT_EQUAL_INT ( - 2 , error ( validErrorCodeMaximumNumberOfAttempts [ i ] ) ) ;
TEST_ASSERT_EQUAL_INT ( - 3 , error ( validErrorCodeNoMenuEntryForNumber [ i ] ) ) ;
}
}