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.

145 lines
2.1 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 validAge[83];
  15. bool validAgeResult[83];
  16. int j=0;
  17. for(int i =18;i<101;i++){
  18. validAge[j]= i;
  19. j++;
  20. }
  21. //Act
  22. for(int i=0;i<83;i++){
  23. validAgeResult[i] = agePermission(validAge[i]);
  24. }
  25. //Assert
  26. for(int i=0;i<83;i++){
  27. TEST_ASSERT_TRUE(validAgeResult[i]);
  28. }
  29. }
  30. void test_agePermissionInvalidAge(void)
  31. {
  32. //Test case : 1
  33. //Arrange
  34. int invalidAge[117];
  35. bool invalidAgeResult[117];
  36. int j=0;
  37. for(int i =-100;i<18;i++){
  38. invalidAge[j]= i;
  39. j++;
  40. }
  41. //Act
  42. for(int i=0;i<117;i++){
  43. invalidAgeResult[i] = agePermission(invalidAge[i]);
  44. }
  45. //Assert
  46. for(int i=0;i<117;i++){
  47. TEST_ASSERT_FALSE(invalidAgeResult[i]);
  48. }
  49. }
  50. void test_IsInteger(void)
  51. {
  52. //Arrange
  53. char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" };
  54. bool inputIsIntegerResult[19];
  55. //Act
  56. for(int i=0;i<19;i++)
  57. {
  58. inputIsIntegerResult[i] = checkIfInteger(inputIsInteger[i]);
  59. }
  60. //Assert
  61. for(int i=0;i<19;i++)
  62. {
  63. TEST_ASSERT_TRUE(inputIsIntegerResult[i]);
  64. }
  65. }
  66. void test_IsNotInteger(void)
  67. {
  68. //Arrange
  69. char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" };
  70. bool inputIsNotIntegerResult[19];
  71. //Act
  72. for(int i=0;i<19;i++)
  73. {
  74. inputIsNotIntegerResult[i] = checkIfInteger(inputIsNotInteger[i]);
  75. }
  76. //Assert
  77. for(int i=0;i<19;i++)
  78. {
  79. TEST_ASSERT_FALSE(inputIsNotIntegerResult[i]);
  80. }
  81. }
  82. #endif // TEST