Main.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import Tests;
  2. import Core.Logger;
  3. import Core.Test;
  4. import Core.Utility;
  5. import Core.Std;
  6. static void finalize() {
  7. Core::finalizeTests();
  8. Core::printMemoryReport();
  9. }
  10. static void onExit(int code, void* data) {
  11. unsigned int i = *static_cast<unsigned int*>(data);
  12. Core::logWarning("Hello from exit #: #", code, i);
  13. finalize();
  14. }
  15. int main(int argAmount, const char** args) {
  16. if(argAmount >= 2 && strcmp(args[1], "help") == 0) {
  17. puts("alloc");
  18. puts("realloc");
  19. puts("alloc_new");
  20. puts("pre_canary");
  21. puts("pre_canary_new");
  22. puts("pre_canary_new_array");
  23. puts("post_canary");
  24. puts("test;ignore");
  25. puts("terminal");
  26. puts("light;testData/readLineTest");
  27. return 0;
  28. }
  29. setlocale(CORE_LC_ALL, "en_US.utf8");
  30. bool light = false;
  31. for(int i = 0; i < argAmount; i++) {
  32. if(strcmp(args[i], "light") == 0) {
  33. light = true;
  34. } else if(strcmp(args[i], "alloc") == 0) {
  35. testInvalidAllocate();
  36. } else if(strcmp(args[i], "realloc") == 0) {
  37. testInvalidReallocate();
  38. } else if(strcmp(args[i], "alloc_new") == 0) {
  39. testInvalidNew();
  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. testArray();
  61. testArrayList(light);
  62. testBitArray();
  63. testBox();
  64. testBuffer(light);
  65. testClock(light);
  66. testColor();
  67. testComponents();
  68. testFile();
  69. testFrustum();
  70. testHashMap(light);
  71. testHashedString();
  72. testList(light);
  73. testMath();
  74. testMatrix();
  75. testPlane();
  76. testQuaternion();
  77. testQueue();
  78. testRandom(light);
  79. if(light) {
  80. testReadLine();
  81. }
  82. testTerminal(!light);
  83. testThread();
  84. testUnicode();
  85. testUniquePointer();
  86. testUtility();
  87. testVector();
  88. testView();
  89. Core::logLevel = Core::LogLevel::WARNING;
  90. Core::logDebug("You won't see this!");
  91. Core::logLevel = Core::LogLevel::DEBUG;
  92. unsigned int data = 123'456'789;
  93. Core::setExitHandler(onExit, &data);
  94. Core::exitWithHandler(1);
  95. }