|
@ -6,37 +6,33 @@ |
|
|
|
|
|
|
|
|
void setUp(void) |
|
|
void setUp(void) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void tearDown(void) |
|
|
void tearDown(void) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void test_agePermissionValidAge(void) |
|
|
void test_agePermissionValidAge(void) |
|
|
{ |
|
|
{ |
|
|
//Test case : 0 |
|
|
//Test case : 0 |
|
|
|
|
|
|
|
|
//Arrange |
|
|
|
|
|
|
|
|
/*Arrange*/ |
|
|
|
|
|
|
|
|
int validAge[83]; |
|
|
|
|
|
|
|
|
int Age = 18; |
|
|
|
|
|
|
|
|
bool validAgeResult[83]; |
|
|
bool validAgeResult[83]; |
|
|
|
|
|
|
|
|
int j=0; |
|
|
|
|
|
|
|
|
/*Act*/ |
|
|
|
|
|
|
|
|
for(int i =18;i<101;i++){ |
|
|
|
|
|
|
|
|
for(int i =0;i<83;i++){ |
|
|
|
|
|
|
|
|
validAge[j]= i; |
|
|
|
|
|
j++; |
|
|
|
|
|
|
|
|
validAgeResult[i]= Age + i; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Act |
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<83;i++){ |
|
|
|
|
|
|
|
|
|
|
|
validAgeResult[i] = agePermission(validAge[i]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Assert |
|
|
|
|
|
|
|
|
/*Assert*/ |
|
|
|
|
|
|
|
|
for(int i=0;i<83;i++){ |
|
|
for(int i=0;i<83;i++){ |
|
|
|
|
|
|
|
@ -51,31 +47,32 @@ void test_agePermissionInvalidAge(void) |
|
|
|
|
|
|
|
|
//Test case : 1 |
|
|
//Test case : 1 |
|
|
|
|
|
|
|
|
//Arrange |
|
|
|
|
|
|
|
|
/*Arrange*/ |
|
|
|
|
|
|
|
|
int invalidAge[117]; |
|
|
int invalidAge[117]; |
|
|
|
|
|
|
|
|
bool invalidAgeResult[117]; |
|
|
bool invalidAgeResult[117]; |
|
|
|
|
|
|
|
|
int j=0; |
|
|
|
|
|
|
|
|
|
|
|
for(int i =-100;i<18;i++){ |
|
|
|
|
|
|
|
|
for(int i =-100;i<18;i++) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
invalidAge[j]= i; |
|
|
|
|
|
j++; |
|
|
|
|
|
|
|
|
invalidAge[i+100]= i; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Act |
|
|
|
|
|
|
|
|
/*Act*/ |
|
|
|
|
|
|
|
|
for(int i=0;i<117;i++){ |
|
|
|
|
|
|
|
|
for(int i=0;i<117;i++) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
invalidAgeResult[i] = agePermission(invalidAge[i]); |
|
|
invalidAgeResult[i] = agePermission(invalidAge[i]); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Assert |
|
|
|
|
|
|
|
|
/*Assert*/ |
|
|
|
|
|
|
|
|
for(int i=0;i<117;i++){ |
|
|
|
|
|
|
|
|
for(int i=0;i<117;i++) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
TEST_ASSERT_FALSE(invalidAgeResult[i]); |
|
|
TEST_ASSERT_FALSE(invalidAgeResult[i]); |
|
|
|
|
|
|
|
@ -86,27 +83,21 @@ void test_agePermissionInvalidAge(void) |
|
|
void test_IsInteger(void) |
|
|
void test_IsInteger(void) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
//Arrange |
|
|
|
|
|
|
|
|
|
|
|
char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" }; |
|
|
|
|
|
|
|
|
|
|
|
bool inputIsIntegerResult[19]; |
|
|
|
|
|
|
|
|
//test case 0 |
|
|
|
|
|
|
|
|
//Act |
|
|
|
|
|
|
|
|
/*Arrange*/ |
|
|
|
|
|
|
|
|
for(int i=0;i<19;i++) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
inputIsIntegerResult[i] = checkIfInteger(inputIsInteger[i]); |
|
|
|
|
|
|
|
|
char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" }; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
bool inputIsIntegerExpected = true; |
|
|
|
|
|
|
|
|
//Assert |
|
|
|
|
|
|
|
|
/*Act and Assert*/ |
|
|
|
|
|
|
|
|
for(int i=0;i<19;i++) |
|
|
for(int i=0;i<19;i++) |
|
|
{ |
|
|
{ |
|
|
|
|
|
bool inputIsIntegerResult = checkIfInteger(inputIsInteger[i]); |
|
|
|
|
|
|
|
|
TEST_ASSERT_TRUE(inputIsIntegerResult[i]); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL(inputIsIntegerExpected,inputIsIntegerResult); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -114,30 +105,25 @@ void test_IsInteger(void) |
|
|
|
|
|
|
|
|
void test_IsNotInteger(void) |
|
|
void test_IsNotInteger(void) |
|
|
{ |
|
|
{ |
|
|
|
|
|
//test case 1 |
|
|
|
|
|
|
|
|
//Arrange |
|
|
|
|
|
|
|
|
/*Arrange*/ |
|
|
|
|
|
|
|
|
char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" }; |
|
|
char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" }; |
|
|
|
|
|
|
|
|
bool inputIsNotIntegerResult[19]; |
|
|
|
|
|
|
|
|
|
|
|
//Act |
|
|
|
|
|
|
|
|
bool inputIsNotIntegerExpected = false; |
|
|
|
|
|
|
|
|
for(int i=0;i<19;i++) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
inputIsNotIntegerResult[i] = checkIfInteger(inputIsNotInteger[i]); |
|
|
|
|
|
|
|
|
/*Act and Assert*/ |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Assert |
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<19;i++) |
|
|
for(int i=0;i<19;i++) |
|
|
{ |
|
|
{ |
|
|
|
|
|
bool inputIsNotIntegerResult = checkIfInteger(inputIsNotInteger[i]); |
|
|
|
|
|
|
|
|
TEST_ASSERT_FALSE(inputIsNotIntegerResult[i]); |
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL(inputIsNotIntegerExpected,inputIsNotIntegerResult); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
#endif // TEST |
|
|
#endif // TEST |