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.

26 lines
1.0 KiB

  1. #include <unity.h>
  2. #include "../src/customerMenu.c"
  3. #include "../src/requestLoan.c"
  4. void test_customerChoiceForMenuEntry()
  5. {
  6. int decision = 1;
  7. unsigned int *ptr = NULL;
  8. /*customer choses to send money, return 1*/
  9. TEST_ASSERT_EQUAL_INT(1, customerChoiceForMenuItem(decision,ptr));
  10. /*customer choses to withdraw money, return 2*/
  11. decision = 2;
  12. TEST_ASSERT_EQUAL_INT(2, customerChoiceForMenuItem(decision,ptr));
  13. /*customer choses to deposit money, return 3*/
  14. decision = 3;
  15. TEST_ASSERT_EQUAL_INT(3, customerChoiceForMenuItem(decision,ptr));
  16. /*customer choses to request a loan, return 4*/
  17. decision = 4;
  18. TEST_ASSERT_EQUAL_INT(4, customerChoiceForMenuItem(decision,ptr));
  19. /*invalid input values, the return value should always be -1*/
  20. int arrayOfInvalidValues[] = {-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20,0, 123,3247,6839,38593,3033,55055};
  21. int length = sizeof(arrayOfInvalidValues)/sizeof(int);
  22. for(int i=0;i<length;++i){
  23. TEST_ASSERT_EQUAL_INT(-1, customerChoiceForMenuItem(arrayOfInvalidValues[i], ptr));
  24. }
  25. }