Main.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #include <clocale>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include "Tests.hpp"
  5. #include "core/Logger.hpp"
  6. #include "core/Test.hpp"
  7. #include "core/Utility.hpp"
  8. static void finalize() {
  9. Core::finalizeTests();
  10. Core::printMemoryReport();
  11. }
  12. static void onExit(int code, void* data) {
  13. unsigned int i = *static_cast<unsigned int*>(data);
  14. LOG_WARNING("Hello from exit #: #", code, i);
  15. finalize();
  16. }
  17. int main(int argAmount, const char** args) {
  18. if(argAmount >= 2 && strcmp(args[1], "help") == 0) {
  19. puts("alloc");
  20. puts("realloc");
  21. puts("alloc_new");
  22. puts("pre_canary");
  23. puts("pre_canary_new");
  24. puts("pre_canary_new_array");
  25. puts("post_canary");
  26. puts("test;ignore");
  27. puts("terminal");
  28. puts("light;testData/readLineTest");
  29. return 0;
  30. }
  31. setlocale(LC_ALL, "en_US.utf8");
  32. bool light = false;
  33. for(int i = 0; i < argAmount; i++) {
  34. if(strcmp(args[i], "light") == 0) {
  35. light = true;
  36. } else if(strcmp(args[i], "alloc") == 0) {
  37. testInvalidAllocate();
  38. } else if(strcmp(args[i], "realloc") == 0) {
  39. testInvalidReallocate();
  40. } else if(strcmp(args[i], "alloc_new") == 0) {
  41. testInvalidNew();
  42. } else if(strcmp(args[i], "pre_canary") == 0) {
  43. testPreCanary();
  44. } else if(strcmp(args[i], "pre_canary_new") == 0) {
  45. testPreCanaryNew();
  46. } else if(strcmp(args[i], "pre_canary_new_array") == 0) {
  47. testPreCanaryNewArray();
  48. } else if(strcmp(args[i], "post_canary") == 0) {
  49. testPostCanary();
  50. } else if(strcmp(args[i], "test") == 0) {
  51. testTest();
  52. return 0;
  53. } else if(strcmp(args[i], "terminal") == 0) {
  54. testTerminal(true);
  55. finalize();
  56. return 0;
  57. } else if(strcmp(args[i], "iterminal") == 0) {
  58. testInteractiveTerminal();
  59. return 0;
  60. }
  61. }
  62. testArray();
  63. testArrayList(light);
  64. testBitArray();
  65. testBox();
  66. testBuffer(light);
  67. testClock(light);
  68. testColor();
  69. testComponents();
  70. testFile();
  71. testFrustum();
  72. testHashMap(light);
  73. testHashedString();
  74. testList(light);
  75. testMath();
  76. testMatrix();
  77. testPlane();
  78. testQuaternion();
  79. testQueue();
  80. testRandom(light);
  81. if(light) {
  82. testReadLine();
  83. }
  84. testTerminal(!light);
  85. testThread();
  86. testUnicode();
  87. testUniquePointer();
  88. testUtility();
  89. testVector();
  90. testView();
  91. Core::logLevel = Core::LogLevel::WARNING;
  92. LOG_DEBUG("You won't see this!");
  93. Core::logLevel = Core::LogLevel::DEBUG;
  94. unsigned int data = 123'456'789;
  95. Core::setExitHandler(onExit, &data);
  96. EXIT(1);
  97. }