Main.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 onExit(int code, void* data) {
  10. unsigned int i = *(unsigned int*)(data);
  11. LOG_WARNING("Hello from exit %d: %u", code, i);
  12. finalizeTests();
  13. printMemoryReport();
  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("pre_canary");
  20. // puts("post_canary");
  21. // puts("test;ignore");
  22. // puts("light;readLineTest");
  23. puts("terminal");
  24. return 0;
  25. }
  26. setlocale(LC_ALL, "en_US.utf8");
  27. bool light = false;
  28. for(int i = 0; i < argAmount; i++) {
  29. if(strcmp(args[i], "light") == 0) {
  30. light = true;
  31. } else if(strcmp(args[i], "alloc") == 0) {
  32. testInvalidAllocate();
  33. } else if(strcmp(args[i], "realloc") == 0) {
  34. testInvalidReallocate();
  35. } else if(strcmp(args[i], "pre_canary") == 0) {
  36. testPreCanary();
  37. } else if(strcmp(args[i], "post_canary") == 0) {
  38. testPostCanary();
  39. } else if(strcmp(args[i], "test") == 0) {
  40. testTest();
  41. return 0;
  42. } else if(strcmp(args[i], "terminal") == 0) {
  43. testTerminal();
  44. return 0;
  45. }
  46. }
  47. testBitArray();
  48. testBox();
  49. testBuffer(light);
  50. testComponents();
  51. testFrustum();
  52. testHashMap(light);
  53. testList(light);
  54. testMatrix();
  55. testPlane();
  56. testQuaternion();
  57. testQueue();
  58. testRandom(light);
  59. logLevel = LOG_NONE;
  60. testReadLine();
  61. logLevel = LOG_DEBUG;
  62. testSpinLock();
  63. testUtility(light);
  64. testVector();
  65. testView();
  66. logLevel = LOG_WARNING;
  67. LOG_DEBUG("You won't see this!");
  68. logLevel = LOG_DEBUG;
  69. unsigned int data = 123'456'789;
  70. setExitHandler(onExit, &data);
  71. EXIT(1);
  72. }