You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
973 B

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "../src/checkLoanEligibility.c"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_checkLoanEligibilitySuccess(void) {
  11. /* Arrange */
  12. int user_id[3] = {1234, 1327, 1666}; // user_ids from file for testing
  13. bool result[3];
  14. /* Act */
  15. for (int i = 0; i < 3; i++) {
  16. result[i] = checkLoanEligibility(user_id[i]);
  17. }
  18. /* Assert */
  19. for (int i = 0; i < 3; i++) {
  20. TEST_ASSERT_TRUE(result[i]); // Pass if user_id is found in the file
  21. }
  22. }
  23. void test_checkLoanEligibilityFailure(void) {
  24. /* Arrange */
  25. int user_id[3] = {12314, 127, 166}; // Random wrong user_ids
  26. bool result[3];
  27. /* Act */
  28. for (int i = 0; i < 3; i++) {
  29. result[i] = checkLoanEligibility(user_id[i]);
  30. }
  31. /* Assert */
  32. for (int i = 0; i < 3; i++) {
  33. TEST_ASSERT_FALSE(result[i]); // Pass if the returned result is false
  34. }
  35. }
  36. #endif // TEST