Main.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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("pre_canary");
  22. puts("pre_canary_new");
  23. puts("pre_canary_new_array");
  24. puts("post_canary");
  25. puts("test;ignore");
  26. puts("terminal");
  27. puts("light;testData/readLineTest");
  28. return 0;
  29. }
  30. setlocale(LC_ALL, "en_US.utf8");
  31. bool light = false;
  32. for(int i = 0; i < argAmount; i++) {
  33. if(strcmp(args[i], "light") == 0) {
  34. light = true;
  35. } else if(strcmp(args[i], "alloc") == 0) {
  36. testInvalidAllocate();
  37. } else if(strcmp(args[i], "realloc") == 0) {
  38. testInvalidReallocate();
  39. } else if(strcmp(args[i], "pre_canary") == 0) {
  40. testPreCanary();
  41. } else if(strcmp(args[i], "pre_canary_new") == 0) {
  42. testPreCanaryNew();
  43. } else if(strcmp(args[i], "pre_canary_new_array") == 0) {
  44. testPreCanaryNewArray();
  45. } else if(strcmp(args[i], "post_canary") == 0) {
  46. testPostCanary();
  47. } else if(strcmp(args[i], "test") == 0) {
  48. testTest();
  49. return 0;
  50. } else if(strcmp(args[i], "terminal") == 0) {
  51. testTerminal(true);
  52. finalize();
  53. return 0;
  54. } else if(strcmp(args[i], "iterminal") == 0) {
  55. testInteractiveTerminal();
  56. return 0;
  57. }
  58. }
  59. testList(light);
  60. testUniquePointer();
  61. testVector();
  62. testMath();
  63. testArray();
  64. // testBitArray();
  65. testBox();
  66. // testBuffer(light);
  67. // testComponents();
  68. testFile();
  69. // testFrustum();
  70. // testHashMap(light);
  71. testMatrix();
  72. testPlane();
  73. testQuaternion();
  74. // testQueue();
  75. testRandom(light);
  76. if(light) {
  77. // testReadLine();
  78. }
  79. // testSpinLock();
  80. testTerminal(!light);
  81. testUnicode();
  82. testUtility(light);
  83. testView();
  84. logLevel = LogLevel::WARNING;
  85. LOG_DEBUG("You won't see this!");
  86. logLevel = LogLevel::DEBUG;
  87. unsigned int data = 123'456'789;
  88. Core::setExitHandler(onExit, &data);
  89. EXIT(1);
  90. }