Main.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include <locale.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <threads.h>
  5. #include "Tests.h"
  6. #include "core/Logger.h"
  7. #include "core/Test.h"
  8. #include "core/Utility.h"
  9. static void finalize() {
  10. finalizeTests();
  11. printMemoryReport();
  12. }
  13. static void onExit(int code, void* data) {
  14. unsigned int i = *(unsigned int*)(data);
  15. LOG_WARNING("Hello from exit %d: %u", 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("post_canary");
  24. puts("test;ignore");
  25. puts("terminal");
  26. puts("light;testData/readLineTest");
  27. return 0;
  28. }
  29. setlocale(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], "pre_canary") == 0) {
  39. testPreCanary();
  40. } else if(strcmp(args[i], "post_canary") == 0) {
  41. testPostCanary();
  42. } else if(strcmp(args[i], "test") == 0) {
  43. testTest();
  44. return 0;
  45. } else if(strcmp(args[i], "terminal") == 0) {
  46. testTerminal(true);
  47. finalize();
  48. return 0;
  49. } else if(strcmp(args[i], "iterminal") == 0) {
  50. testInteractiveTerminal();
  51. return 0;
  52. }
  53. }
  54. testBitArray();
  55. testBox();
  56. testBuffer(light);
  57. testComponents();
  58. testFile();
  59. testFrustum();
  60. testHashMap(light);
  61. testList(light);
  62. testMatrix();
  63. testPlane();
  64. testQuaternion();
  65. testQueue();
  66. testRandom(light);
  67. if(light) {
  68. testReadLine();
  69. }
  70. testSpinLock();
  71. testTerminal(!light);
  72. testUnicode();
  73. testUtility(light);
  74. testVector();
  75. testView();
  76. logLevel = LOG_WARNING;
  77. LOG_DEBUG("You won't see this!");
  78. logLevel = LOG_DEBUG;
  79. unsigned int data = 123'456'789;
  80. setExitHandler(onExit, &data);
  81. EXIT(1);
  82. }