Browse Source

bug fix: Solve test errors.

remotes/origin/Alpha
fdai7057 2 years ago
parent
commit
3f9dcb0e07
  1. 26
      tests/test_CustomerMenu.c
  2. 7
      tests/test_LoginCustomer.c
  3. 8
      tests/test_mainMenu.c

26
tests/test_CustomerMenu.c

@ -1,26 +0,0 @@
#include <unity.h>
#include "../src/customerMenu.c"
#include "../src/requestLoan.c"
void test_customerChoiceForMenuEntry()
{
int decision = 1;
unsigned int *ptr = NULL;
/*customer choses to send money, return 1*/
TEST_ASSERT_EQUAL_INT(1, customerChoiceForMenuItem(decision,ptr));
/*customer choses to withdraw money, return 2*/
decision = 2;
TEST_ASSERT_EQUAL_INT(2, customerChoiceForMenuItem(decision,ptr));
/*customer choses to deposit money, return 3*/
decision = 3;
TEST_ASSERT_EQUAL_INT(3, customerChoiceForMenuItem(decision,ptr));
/*customer choses to request a loan, return 4*/
decision = 4;
TEST_ASSERT_EQUAL_INT(4, customerChoiceForMenuItem(decision,ptr));
/*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<length;++i){
TEST_ASSERT_EQUAL_INT(-1, customerChoiceForMenuItem(arrayOfInvalidValues[i], ptr));
}
}

7
tests/test_LoginCustomer.c

@ -4,6 +4,13 @@
#include "../src/helperFunctions.c"
#include "../src/requestLoan.c"
#include "../src/error.c"
#include "../src/sendMoney.c"
#include "../src/withdrawMoney.c"
#include "../src/depositMoney.c"
#include "../src/currencyExchange.c"
#include "../src/updateCustomerAccountBalance.c"
#include "../src/currentCustomerAccountBalance.c"
void setUp(){};
void tearDown(){};
void test_checkLogin()

8
tests/test_mainMenu.c

@ -22,6 +22,14 @@
#include "../src/displayMenuCalculator.c"
#include "../src/requestLoan.c"
#include "../src/sendMoney.c"
#include "../src/withdrawMoney.c"
#include "../src/depositMoney.c"
#include "../src/currencyExchange.c"
#include "../src/updateCustomerAccountBalance.c"
#include "../src/currentCustomerAccountBalance.c"
void setUp(void)
{

Loading…
Cancel
Save