From f9e48c96da424fd69b131c06086f3cc14fe7f630 Mon Sep 17 00:00:00 2001 From: Shivam Chaudhary Date: Fri, 10 Feb 2023 09:21:52 +0100 Subject: [PATCH] Add test for withdrawSpecificAmount for failure --- tests/test_withdrawMoney.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_withdrawMoney.c b/tests/test_withdrawMoney.c index d4c6045..8070c4f 100644 --- a/tests/test_withdrawMoney.c +++ b/tests/test_withdrawMoney.c @@ -63,6 +63,28 @@ void test_withdrawSpecificAmountSuccess(void) { } +void test_withdrawSpecificAmountFailure(void) { + + /* Arrange */ + + int user_id[3] = {12034, 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 + } + +} +