Main.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #include <locale.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <threads.h>
  5. #include "Tests.hpp"
  6. #include "core/Logger.hpp"
  7. #include "core/Test.hpp"
  8. #include "core/Utility.hpp"
  9. static void finalize() {
  10. Core::finalizeTests();
  11. Core::printMemoryReport();
  12. }
  13. static void onExit(int code, void* data) {
  14. unsigned int i = *static_cast<unsigned int*>(data);
  15. LOG_WARNING("Hello from exit #: #", code, i);
  16. finalize();
  17. }
  18. int main(int argAmount, const char** args) {
  19. if(argAmount >= 2 && strcmp(args[1], "help") == 0) {
  20. puts("alloc");
  21. puts("realloc");
  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], "pre_canary") == 0) {
  41. testPreCanary();
  42. } else if(strcmp(args[i], "pre_canary_new") == 0) {
  43. testPreCanaryNew();
  44. } else if(strcmp(args[i], "pre_canary_new_array") == 0) {
  45. testPreCanaryNewArray();
  46. } else if(strcmp(args[i], "post_canary") == 0) {
  47. testPostCanary();
  48. } else if(strcmp(args[i], "test") == 0) {
  49. testTest();
  50. return 0;
  51. } else if(strcmp(args[i], "terminal") == 0) {
  52. // testTerminal(true);
  53. finalize();
  54. return 0;
  55. } else if(strcmp(args[i], "iterminal") == 0) {
  56. // testInteractiveTerminal();
  57. return 0;
  58. }
  59. }
  60. testList(light);
  61. testUniquePointer();
  62. testVector();
  63. testMath();
  64. testArray();
  65. // testBitArray();
  66. // testBox();
  67. // testBuffer(light);
  68. // testComponents();
  69. testFile();
  70. // testFrustum();
  71. // testHashMap(light);
  72. // testList(light);
  73. testMatrix();
  74. // testPlane();
  75. testQuaternion();
  76. // testQueue();
  77. testRandom(light);
  78. if(light) {
  79. // testReadLine();
  80. }
  81. // testSpinLock();
  82. // testTerminal(!light);
  83. // testUnicode();
  84. testUtility(light);
  85. // testVector();
  86. // testView();
  87. logLevel = LogLevel::WARNING;
  88. LOG_DEBUG("You won't see this!");
  89. logLevel = LogLevel::DEBUG;
  90. unsigned int data = 123'456'789;
  91. Core::setExitHandler(onExit, &data);
  92. EXIT(1);
  93. }