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.

129 lines
1.9 KiB

  1. #ifdef TEST
  2. #include "unity.h"
  3. #include "mainMenu.h"
  4. void setUp(void)
  5. {
  6. }
  7. void tearDown(void)
  8. {
  9. }
  10. void test_agePermissionValidAge(void)
  11. {
  12. //Test case : 0
  13. /*Arrange*/
  14. int Age = 18;
  15. bool validAgeResult[83];
  16. /*Act*/
  17. for(int i =0;i<83;i++){
  18. validAgeResult[i]= Age + i;
  19. }
  20. /*Assert*/
  21. for(int i=0;i<83;i++){
  22. TEST_ASSERT_TRUE(validAgeResult[i]);
  23. }
  24. }
  25. void test_agePermissionInvalidAge(void)
  26. {
  27. //Test case : 1
  28. /*Arrange*/
  29. int invalidAge[117];
  30. bool invalidAgeResult[117];
  31. for(int i =-100;i<18;i++)
  32. {
  33. invalidAge[i+100]= i;
  34. }
  35. /*Act*/
  36. for(int i=0;i<117;i++)
  37. {
  38. invalidAgeResult[i] = agePermission(invalidAge[i]);
  39. }
  40. /*Assert*/
  41. for(int i=0;i<117;i++)
  42. {
  43. TEST_ASSERT_FALSE(invalidAgeResult[i]);
  44. }
  45. }
  46. void test_IsInteger(void)
  47. {
  48. //test case 0
  49. /*Arrange*/
  50. char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" };
  51. bool inputIsIntegerExpected = true;
  52. /*Act and Assert*/
  53. for(int i=0;i<19;i++)
  54. {
  55. bool inputIsIntegerResult = checkIfInteger(inputIsInteger[i]);
  56. TEST_ASSERT_EQUAL(inputIsIntegerExpected,inputIsIntegerResult);
  57. }
  58. }
  59. void test_IsNotInteger(void)
  60. {
  61. //test case 1
  62. /*Arrange*/
  63. char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" };
  64. bool inputIsNotIntegerExpected = false;
  65. /*Act and Assert*/
  66. for(int i=0;i<19;i++)
  67. {
  68. bool inputIsNotIntegerResult = checkIfInteger(inputIsNotInteger[i]);
  69. TEST_ASSERT_EQUAL(inputIsNotIntegerExpected,inputIsNotIntegerResult);
  70. }
  71. }
  72. #endif // TEST