From 0f7ae88baa4b29f9189c8a66e52e955697c58f9b Mon Sep 17 00:00:00 2001 From: fdai7057 Date: Mon, 6 Feb 2023 15:31:58 +0100 Subject: [PATCH] Implementation of unit test for function customerChoiceForMenuItem(). --- test/test_CustomerMenu.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/test_CustomerMenu.c diff --git a/test/test_CustomerMenu.c b/test/test_CustomerMenu.c new file mode 100644 index 0000000..4ba1f23 --- /dev/null +++ b/test/test_CustomerMenu.c @@ -0,0 +1,24 @@ +#include +#include "../src/customerMenu.c" + +void test_customerChoiceForMenuEntry() +{ + int decision = 1; + /*customer choses to send money, return 1*/ + TEST_ASSERT_EQUAL_INT(1, customerChoiceForMenuItem(decision)); + /*customer choses to withdraw money, return 2*/ + decision = 2; + TEST_ASSERT_EQUAL_INT(2, customerChoiceForMenuItem(decision)); + /*customer choses to deposit money, return 3*/ + decision = 3; + TEST_ASSERT_EQUAL_INT(3, customerChoiceForMenuItem(decision)); + /*customer choses to request a loan, return 4*/ + decision = 4; + TEST_ASSERT_EQUAL_INT(4, customerChoiceForMenuItem(decision)); + /*invalid input values, the return value should always be -1*/ + int arrayOfInvalidValues[] = {-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20,0, 123,3247,6839,38593,3033,55055}; + int length = sizeof(arrayOfInvalidValues)/sizeof(int); + for(int i=0;i