|
@ -0,0 +1,57 @@ |
|
|
|
|
|
#ifdef TEST |
|
|
|
|
|
|
|
|
|
|
|
#include "unity.h" |
|
|
|
|
|
#include "checkLoanEligibility.h" |
|
|
|
|
|
|
|
|
|
|
|
void setUp(void) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void tearDown(void) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_checkLoanEligibilitySuccess(void) { |
|
|
|
|
|
|
|
|
|
|
|
/* Arrange */ |
|
|
|
|
|
|
|
|
|
|
|
int user_id[3] = {1234, 1327, 1666}; // user_ids from file for testing |
|
|
|
|
|
|
|
|
|
|
|
bool result[3]; |
|
|
|
|
|
|
|
|
|
|
|
/* Act */ |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
|
|
result[i] = checkLoanEligibility(user_id[i]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Assert */ |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
|
|
TEST_ASSERT_TRUE(result[i]); // Pass if user_id is found in the file |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void test_checkLoanEligibilityFailure(void) { |
|
|
|
|
|
|
|
|
|
|
|
/* Arrange */ |
|
|
|
|
|
|
|
|
|
|
|
int user_id[3] = {12314, 127, 166}; // Random wrong user_ids |
|
|
|
|
|
|
|
|
|
|
|
bool result[3]; |
|
|
|
|
|
|
|
|
|
|
|
/* Act */ |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
|
|
result[i] = checkLoanEligibility(user_id[i]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Assert */ |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
|
|
TEST_ASSERT_FALSE(result[i]); // Pass if the returned result is false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // TEST |