Main.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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;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. testFrustum();
  59. testHashMap(light);
  60. testList(light);
  61. testMatrix();
  62. testPlane();
  63. testQuaternion();
  64. testQueue();
  65. testRandom(light);
  66. logLevel = LOG_NONE;
  67. if(light) {
  68. testReadLine();
  69. }
  70. logLevel = LOG_DEBUG;
  71. testSpinLock();
  72. testTerminal(!light);
  73. testUnicode();
  74. testUtility(light);
  75. testVector();
  76. testView();
  77. logLevel = LOG_WARNING;
  78. LOG_DEBUG("You won't see this!");
  79. logLevel = LOG_DEBUG;
  80. unsigned int data = 123'456'789;
  81. setExitHandler(onExit, &data);
  82. EXIT(1);
  83. }