#ifdef TEST #include "unity.h" #include "../src/withdrawMoney.c" #include "../src/updateCustomerAccountBalance.c" #include "../src/currentCustomerAccountBalance.c" void setUp(void) { } void tearDown(void) { } void test_initiateWithdraw(void) { /* Arrange */ int length = 10; float amountToWithdraw[] = {200.5, 340, 244.5, 340, 1200, 3232, 1123, 460.5, 900, 1005}; float availableAccountBalance[] = {2000, 3400, 2445, 3400, 6000, 5000, 1000, 2000, 2000, 9000}; float expectedValue[length]; float result[length]; /* Act */ for (int i = 0; i < length; i++) { result[i] = initiateWithdraw( amountToWithdraw[i], availableAccountBalance[i] ); } /* Assert */ for (int i = 0; i < length; i++) { expectedValue[i] = ( availableAccountBalance[i] - amountToWithdraw[i] ); } for (int i = 0; i < length; i++) { TEST_ASSERT_EQUAL_FLOAT(expectedValue[i],result[i]); } } void test_withdrawSpecificAmountSuccess(void) { /* Arrange */ int user_id[3] = {1234, 1235, 1236}; // user_ids from file for testing bool result[3]; /* Act */ for (int i = 0; i < 3; i++) { result[i] = withdrawSpecificAmount(user_id[i], 50); } /* Assert */ for (int i = 0; i < 3; i++) { TEST_ASSERT_TRUE(result[i]); // Pass if withdrawal is successful } } void test_withdrawSpecificAmountFailure(void) { /* Arrange */ int user_id[3] = {12934, 13027, 16606}; // Random wrong user_ids bool result[3]; /* Act */ for (int i = 0; i < 3; i++) { result[i] = withdrawSpecificAmount(user_id[i], 50); } /* Assert */ for (int i = 0; i < 3; i++) { TEST_ASSERT_FALSE(result[i]); // Pass if withdrawal fails and function returns false } } #endif // TEST