Main.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include <locale.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "Tests.h"
  5. #include "core/Logger.h"
  6. #include "core/Test.h"
  7. #include "core/Utility.h"
  8. static void onExit(int code, void* data) {
  9. unsigned int i = *(unsigned int*)(data);
  10. LOG_WARNING("Hello from exit %d: %u", code, i);
  11. finalizeTests();
  12. printMemoryReport();
  13. }
  14. int main(int argAmount, const char** args) {
  15. if(argAmount >= 2 && strcmp(args[1], "help") == 0) {
  16. puts("alloc");
  17. puts("realloc");
  18. puts("pre_canary");
  19. puts("post_canary");
  20. puts("test;ignore");
  21. puts("light;readLineTest");
  22. return 0;
  23. }
  24. setlocale(LC_ALL, "en_US.utf8");
  25. bool light = false;
  26. for(int i = 0; i < argAmount; i++) {
  27. if(strcmp(args[i], "light") == 0) {
  28. light = true;
  29. } else if(strcmp(args[i], "alloc") == 0) {
  30. testInvalidAllocate();
  31. } else if(strcmp(args[i], "realloc") == 0) {
  32. testInvalidReallocate();
  33. } else if(strcmp(args[i], "pre_canary") == 0) {
  34. testPreCanary();
  35. } else if(strcmp(args[i], "post_canary") == 0) {
  36. testPostCanary();
  37. } else if(strcmp(args[i], "test") == 0) {
  38. testTest();
  39. return 0;
  40. }
  41. }
  42. testBitArray();
  43. testBox();
  44. testBuffer(light);
  45. testComponents();
  46. testFrustum();
  47. testHashMap(light);
  48. testList(light);
  49. testMatrix();
  50. testPlane();
  51. testQuaternion();
  52. testQueue();
  53. testRandom(light);
  54. logLevel = LOG_NONE;
  55. testReadLine();
  56. logLevel = LOG_DEBUG;
  57. testSpinLock();
  58. testUtility(light);
  59. testVector();
  60. testView();
  61. logLevel = LOG_WARNING;
  62. LOG_DEBUG("You won't see this!");
  63. logLevel = LOG_DEBUG;
  64. unsigned int data = 123456789;
  65. setExitHandler(onExit, &data);
  66. EXIT(1);
  67. }