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.

61 lines
1.2 KiB

  1. #include "unity.h"
  2. #include "../src/currentCustomerAccountBalance.c"
  3. #include "../src/depositMoney.c"
  4. #include "../src/updateCustomerAccountBalance.c"
  5. void setUp(void)
  6. {
  7. }
  8. void tearDown(void)
  9. {
  10. }
  11. void test_depositSpecificAmount(void) {
  12. /* Arrange */
  13. int length = 5;
  14. int userIDs[] = {1234,1235,1236,1237,1238};
  15. float amountToDeposit[] = {200.5, 340, 244.5, 340, 1200};
  16. bool result[length];
  17. /* Act */
  18. for (int i = 0; i < length; i++) {
  19. result[i] = depositSpecificAmount( userIDs[i], amountToDeposit[i] );
  20. }
  21. /* Assert */
  22. for (int i = 0; i < length; i++) {
  23. TEST_ASSERT_TRUE(result[i]);
  24. }
  25. }
  26. void test_depositSpecificAmountFail(void) {
  27. /* Arrange */
  28. int length = 5;
  29. int userIDs[] = {1234,1235,1236,1237,1238};
  30. float amountToDeposit[] = {-23, -3, -234, -23, -400};
  31. bool result[length];
  32. /* Act */
  33. for (int i = 0; i < length; i++) {
  34. result[i] = depositSpecificAmount( userIDs[i], amountToDeposit[i] );
  35. }
  36. /* Assert */
  37. for (int i = 0; i < length; i++) {
  38. TEST_ASSERT_FALSE(result[i]);
  39. }
  40. }