From 82acaece2cc0cf674da2308d0fe9a840f2a9b90c Mon Sep 17 00:00:00 2001 From: Shivam Chaudhary Date: Tue, 7 Feb 2023 10:57:29 +0100 Subject: [PATCH] Create test for initiateWithdraw function --- tests/test_withdrawMoney.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/test_withdrawMoney.c diff --git a/tests/test_withdrawMoney.c b/tests/test_withdrawMoney.c new file mode 100644 index 0000000..850d920 --- /dev/null +++ b/tests/test_withdrawMoney.c @@ -0,0 +1,37 @@ +#ifdef TEST + +#include "unity.h" +#include "withdrawMoney.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_initiateWithdraw(void) { + float amountToWithdraw[] = {200.5, 340, 244.5, 340}; + float availableAccountBalance[] = {2000, 3400, 2445, 3400}; + float expectedValue[4]; + float result[4]; + + for (int i = 0; i < 4; i++) { + expectedValue[i] = ( availableAccountBalance[i] - amountToWithdraw[i] ); + } + + for (int i = 0; i < 4; i++) { + result[i] = initiateWithdraw( amountToWithdraw[i], availableAccountBalance[i] ); + } + + for (int i = 0; i < 4; i++) { + TEST_ASSERT_EQUAL_FLOAT(expectedValue[i],result[i]); + } + +} + + + + +#endif // TEST