AutoDeplete_test.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /**
  2. * @file
  3. * @author Marek Bel
  4. */
  5. #include "catch.hpp"
  6. #include "../Firmware/AutoDeplete.h"
  7. TEST_CASE( "AutoDeplete test.", "[AutoDeplete]" )
  8. {
  9. CHECK(ad_allDepleted() == false);
  10. CHECK(ad_getAlternative(0) == 0);
  11. CHECK(ad_getAlternative(1) == 1);
  12. CHECK(ad_getAlternative(2) == 2);
  13. CHECK(ad_getAlternative(3) == 3);
  14. CHECK(ad_getAlternative(4) == 4);
  15. ad_markDepleted(1);
  16. CHECK(ad_getAlternative(0) == 0);
  17. CHECK(ad_getAlternative(1) == 2);
  18. CHECK(ad_getAlternative(2) == 2);
  19. CHECK(ad_getAlternative(3) == 3);
  20. CHECK(ad_getAlternative(4) == 4);
  21. CHECK(ad_allDepleted() == false);
  22. ad_markDepleted(3);
  23. CHECK(ad_getAlternative(0) == 0);
  24. CHECK(ad_getAlternative(1) == 2);
  25. CHECK(ad_getAlternative(2) == 2);
  26. CHECK(ad_getAlternative(3) == 4);
  27. CHECK(ad_getAlternative(4) == 4);
  28. CHECK(ad_allDepleted() == false);
  29. ad_markDepleted(4);
  30. CHECK(ad_getAlternative(0) == 0);
  31. CHECK(ad_getAlternative(1) == 2);
  32. CHECK(ad_getAlternative(2) == 2);
  33. CHECK(ad_getAlternative(3) == 0);
  34. CHECK(ad_getAlternative(4) == 0);
  35. CHECK(ad_allDepleted() == false);
  36. ad_markDepleted(4);
  37. CHECK(ad_getAlternative(0) == 0);
  38. CHECK(ad_getAlternative(1) == 2);
  39. CHECK(ad_getAlternative(2) == 2);
  40. CHECK(ad_getAlternative(3) == 0);
  41. CHECK(ad_getAlternative(4) == 0);
  42. CHECK(ad_allDepleted() == false);
  43. ad_markDepleted(0);
  44. CHECK(ad_getAlternative(0) == 2);
  45. CHECK(ad_getAlternative(1) == 2);
  46. CHECK(ad_getAlternative(2) == 2);
  47. CHECK(ad_getAlternative(3) == 2);
  48. CHECK(ad_getAlternative(4) == 2);
  49. CHECK(ad_allDepleted() == false);
  50. ad_markDepleted(2);
  51. CHECK(ad_getAlternative(0) == 0);
  52. CHECK(ad_getAlternative(1) == 1);
  53. CHECK(ad_getAlternative(2) == 2);
  54. CHECK(ad_getAlternative(3) == 3);
  55. CHECK(ad_getAlternative(4) == 4);
  56. CHECK(ad_allDepleted() == true);
  57. ad_markDepleted(2);
  58. CHECK(ad_getAlternative(0) == 0);
  59. CHECK(ad_getAlternative(1) == 1);
  60. CHECK(ad_getAlternative(2) == 2);
  61. CHECK(ad_getAlternative(3) == 3);
  62. CHECK(ad_getAlternative(4) == 4);
  63. CHECK(ad_allDepleted() == true);
  64. ad_markLoaded(4);
  65. CHECK(ad_getAlternative(0) == 4);
  66. CHECK(ad_getAlternative(1) == 4);
  67. CHECK(ad_getAlternative(2) == 4);
  68. CHECK(ad_getAlternative(3) == 4);
  69. CHECK(ad_getAlternative(4) == 4);
  70. CHECK(ad_allDepleted() == false);
  71. ad_markLoaded(0);
  72. CHECK(ad_getAlternative(0) == 0);
  73. CHECK(ad_getAlternative(1) == 4);
  74. CHECK(ad_getAlternative(2) == 4);
  75. CHECK(ad_getAlternative(3) == 4);
  76. CHECK(ad_getAlternative(4) == 4);
  77. CHECK(ad_allDepleted() == false);
  78. ad_markLoaded(3);
  79. CHECK(ad_getAlternative(0) == 0);
  80. CHECK(ad_getAlternative(1) == 3);
  81. CHECK(ad_getAlternative(2) == 3);
  82. CHECK(ad_getAlternative(3) == 3);
  83. CHECK(ad_getAlternative(4) == 4);
  84. CHECK(ad_allDepleted() == false);
  85. ad_markLoaded(3);
  86. CHECK(ad_getAlternative(0) == 0);
  87. CHECK(ad_getAlternative(1) == 3);
  88. CHECK(ad_getAlternative(2) == 3);
  89. CHECK(ad_getAlternative(3) == 3);
  90. CHECK(ad_getAlternative(4) == 4);
  91. CHECK(ad_allDepleted() == false);
  92. ad_markLoaded(2);
  93. CHECK(ad_getAlternative(0) == 0);
  94. CHECK(ad_getAlternative(1) == 2);
  95. CHECK(ad_getAlternative(2) == 2);
  96. CHECK(ad_getAlternative(3) == 3);
  97. CHECK(ad_getAlternative(4) == 4);
  98. CHECK(ad_allDepleted() == false);
  99. ad_markLoaded(1);
  100. CHECK(ad_getAlternative(0) == 0);
  101. CHECK(ad_getAlternative(1) == 1);
  102. CHECK(ad_getAlternative(2) == 2);
  103. CHECK(ad_getAlternative(3) == 3);
  104. CHECK(ad_getAlternative(4) == 4);
  105. CHECK(ad_allDepleted() == false);
  106. ad_markLoaded(1);
  107. CHECK(ad_getAlternative(0) == 0);
  108. CHECK(ad_getAlternative(1) == 1);
  109. CHECK(ad_getAlternative(2) == 2);
  110. CHECK(ad_getAlternative(3) == 3);
  111. CHECK(ad_getAlternative(4) == 4);
  112. CHECK(ad_allDepleted() == false);
  113. }