You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

246 lines
4.1 KiB

#ifdef TEST
#include "unity.h"
#include "../src/mainMenu.c"
#include "../src/error.c"
#include "../src/loginCustomer.c"
#include "../src/helperFunctions.c"
#include "../src/createCustomer.c"
#include "../src/employeeLogin.c"
#include "../src/createEmployeeAccount.c"
#include "../src/customerMenu.c"
#include "../src/showGeneralInfoEmployee.c"
#include "../src/calculatorAdd.c"
#include "../src/calculatorDivide.c"
#include "../src/calculatorFactorial.c"
#include "../src/calculatorGetUserInput.c"
#include "../src/calculatorGetUserInputFactorial.c"
#include "../src/calculatorMultiply.c"
#include "../src/calculatorSubtract.c"
#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)
{
}
void tearDown(void)
{
}
void test_agePermissionValidAge(void)
{
//Test case : 0
/*Arrange*/
int Age = 18;
bool validAgeResult[83];
/*Act*/
for(int i =0; i < 83; i++){
validAgeResult[i]= agePermission(Age + i);
}
/*Assert*/
for(int i=0; i < 83; i++){
TEST_ASSERT_TRUE(validAgeResult[i]);
}
}
void test_agePermissionInvalidAge(void)
{
//Test case : 1
/*Arrange*/
int invalidAge[117];
bool invalidAgeResult[117];
for(int i =-100; i < 18; i++)
{
invalidAge[i+100]= i;
}
/*Act*/
for(int i=0; i < 117; i++)
{
invalidAgeResult[i] = agePermission(invalidAge[i]);
}
/*Assert*/
for(int i=0; i < 117; i++)
{
TEST_ASSERT_FALSE(invalidAgeResult[i]);
}
}
void test_IsInteger(void)
{
//test case 0
/*Arrange*/
char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" };
bool inputIsIntegerExpected = true;
/*Act and Assert*/
for(int i=0; i < 19; i++)
{
bool inputIsIntegerResult = checkIfInteger(inputIsInteger[i]);
TEST_ASSERT_EQUAL(inputIsIntegerExpected,inputIsIntegerResult);
}
}
void test_IsNotInteger(void)
{
//test case 1
/*Arrange*/
char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" };
bool inputIsNotIntegerExpected = false;
/*Act and Assert*/
for(int i=0; i<19; i++)
{
bool inputIsNotIntegerResult = checkIfInteger(inputIsNotInteger[i]);
TEST_ASSERT_EQUAL(inputIsNotIntegerExpected,inputIsNotIntegerResult);
}
}
void test_validChoiceInput(void)
{
//test case 0
/*Arrange*/
int validInput[6];
bool validInputExpected = true;
for(int i = 0; i < 6; i++)
{
validInput[i] = i + 1;
}
/*Act and Asssert*/
for(int i = 0; i < 6; i++)
{
bool validInputResult = chooseOption(validInput[i]);
TEST_ASSERT_EQUAL(validInputExpected,validInputResult);
}
}
void test_invalidChoiceInput_firstCase(void)
{
// test case 1
/*Arrange*/
int invalidInput[100];
bool invalidInputExpected = false;
for(int i = -100; i < 1; i++)
{
invalidInput[i+100] = i;
}
/*Act and Assert*/
for(int i = 0; i < 100; i++)
{
bool invalidInputResult = chooseOption(invalidInput[i]);
TEST_ASSERT_EQUAL(invalidInputExpected,invalidInputResult);
}
}
void test_invalidChoiceInput_secondCase(void)
{
// test case 2
/*Arrange*/
int invalidInput[100];
bool invalidInputExpected = false;
for(int i = 0; i < 100; i++)
{
invalidInput[i] = i + 7;
}
/*Act and Assert*/
for(int i = 0; i < 100; i++)
{
bool invalidInputResult = chooseOption(invalidInput[i]);
TEST_ASSERT_EQUAL(invalidInputExpected,invalidInputResult);
}
}
#endif // TEST