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.

47 lines
893 B

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "withdrawMoney.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_initiateWithdraw(void) {
  11. /* Arrange */
  12. int length = 10;
  13. float amountToWithdraw[] = {200.5, 340, 244.5, 340, 1200, 3232, 1123, 460.5, 900, 1005};
  14. float availableAccountBalance[] = {2000, 3400, 2445, 3400, 6000, 5000, 1000, 2000, 2000, 9000};
  15. float expectedValue[length];
  16. float result[length];
  17. /* Act */
  18. for (int i = 0; i < length; i++) {
  19. result[i] = initiateWithdraw( amountToWithdraw[i], availableAccountBalance[i] );
  20. }
  21. /* Assert */
  22. for (int i = 0; i < length; i++) {
  23. expectedValue[i] = ( availableAccountBalance[i] - amountToWithdraw[i] );
  24. }
  25. for (int i = 0; i < length; i++) {
  26. TEST_ASSERT_EQUAL_FLOAT(expectedValue[i],result[i]);
  27. }
  28. }
  29. #endif // TEST