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.

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