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

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "../src/mainMenu.c"
  4. #include "../src/error.c"
  5. #include "../src/loginCustomer.c"
  6. #include "../src/helperFunctions.c"
  7. #include "../src/createCustomer.c"
  8. #include "../src/employeeLogin.c"
  9. #include "../src/createEmployeeAccount.c"
  10. #include "../src/customerMenu.c"
  11. #include "../src/showGeneralInfoEmployee.c"
  12. #include "../src/calculatorAdd.c"
  13. #include "../src/calculatorDivide.c"
  14. #include "../src/calculatorFactorial.c"
  15. #include "../src/calculatorGetUserInput.c"
  16. #include "../src/calculatorGetUserInputFactorial.c"
  17. #include "../src/calculatorMultiply.c"
  18. #include "../src/calculatorSubtract.c"
  19. #include "../src/displayMenuCalculator.c"
  20. #include "../src/requestLoan.c"
  21. #include "../src/sendMoney.c"
  22. #include "../src/withdrawMoney.c"
  23. #include "../src/depositMoney.c"
  24. #include "../src/currencyExchange.c"
  25. #include "../src/updateCustomerAccountBalance.c"
  26. #include "../src/currentCustomerAccountBalance.c"
  27. void setUp(void)
  28. {
  29. }
  30. void tearDown(void)
  31. {
  32. }
  33. void test_agePermissionValidAge(void)
  34. {
  35. //Test case : 0
  36. /*Arrange*/
  37. int Age = 18;
  38. bool validAgeResult[83];
  39. /*Act*/
  40. for(int i =0; i < 83; i++){
  41. validAgeResult[i]= agePermission(Age + i);
  42. }
  43. /*Assert*/
  44. for(int i=0; i < 83; i++){
  45. TEST_ASSERT_TRUE(validAgeResult[i]);
  46. }
  47. }
  48. void test_agePermissionInvalidAge(void)
  49. {
  50. //Test case : 1
  51. /*Arrange*/
  52. int invalidAge[117];
  53. bool invalidAgeResult[117];
  54. for(int i =-100; i < 18; i++)
  55. {
  56. invalidAge[i+100]= i;
  57. }
  58. /*Act*/
  59. for(int i=0; i < 117; i++)
  60. {
  61. invalidAgeResult[i] = agePermission(invalidAge[i]);
  62. }
  63. /*Assert*/
  64. for(int i=0; i < 117; i++)
  65. {
  66. TEST_ASSERT_FALSE(invalidAgeResult[i]);
  67. }
  68. }
  69. void test_IsInteger(void)
  70. {
  71. //test case 0
  72. /*Arrange*/
  73. char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" };
  74. bool inputIsIntegerExpected = true;
  75. /*Act and Assert*/
  76. for(int i=0; i < 19; i++)
  77. {
  78. bool inputIsIntegerResult = checkIfInteger(inputIsInteger[i]);
  79. TEST_ASSERT_EQUAL(inputIsIntegerExpected,inputIsIntegerResult);
  80. }
  81. }
  82. void test_IsNotInteger(void)
  83. {
  84. //test case 1
  85. /*Arrange*/
  86. char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" };
  87. bool inputIsNotIntegerExpected = false;
  88. /*Act and Assert*/
  89. for(int i=0; i<19; i++)
  90. {
  91. bool inputIsNotIntegerResult = checkIfInteger(inputIsNotInteger[i]);
  92. TEST_ASSERT_EQUAL(inputIsNotIntegerExpected,inputIsNotIntegerResult);
  93. }
  94. }
  95. void test_validChoiceInput(void)
  96. {
  97. //test case 0
  98. /*Arrange*/
  99. int validInput[6];
  100. bool validInputExpected = true;
  101. for(int i = 0; i < 6; i++)
  102. {
  103. validInput[i] = i + 1;
  104. }
  105. /*Act and Asssert*/
  106. for(int i = 0; i < 6; i++)
  107. {
  108. bool validInputResult = chooseOption(validInput[i]);
  109. TEST_ASSERT_EQUAL(validInputExpected,validInputResult);
  110. }
  111. }
  112. void test_invalidChoiceInput_firstCase(void)
  113. {
  114. // test case 1
  115. /*Arrange*/
  116. int invalidInput[100];
  117. bool invalidInputExpected = false;
  118. for(int i = -100; i < 1; i++)
  119. {
  120. invalidInput[i+100] = i;
  121. }
  122. /*Act and Assert*/
  123. for(int i = 0; i < 100; i++)
  124. {
  125. bool invalidInputResult = chooseOption(invalidInput[i]);
  126. TEST_ASSERT_EQUAL(invalidInputExpected,invalidInputResult);
  127. }
  128. }
  129. void test_invalidChoiceInput_secondCase(void)
  130. {
  131. // test case 2
  132. /*Arrange*/
  133. int invalidInput[100];
  134. bool invalidInputExpected = false;
  135. for(int i = 0; i < 100; i++)
  136. {
  137. invalidInput[i] = i + 7;
  138. }
  139. /*Act and Assert*/
  140. for(int i = 0; i < 100; i++)
  141. {
  142. bool invalidInputResult = chooseOption(invalidInput[i]);
  143. TEST_ASSERT_EQUAL(invalidInputExpected,invalidInputResult);
  144. }
  145. }
  146. #endif // TEST