main.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "Utils/RobotLoggingUtil.h"
  2. #ifndef ENABLE_GTEST
  3. #include <assert.h>
  4. #define ASSERT_EQ(a, b) assert((a) == (b));
  5. #else
  6. #include <gtest/gtest.h>
  7. #define printf
  8. #endif
  9. void testMinitaurLogging()
  10. {
  11. const char* fileName = "d:/logTest.txt";
  12. btAlignedObjectArray<std::string> structNames;
  13. std::string structTypes;
  14. btAlignedObjectArray<MinitaurLogRecord> logRecords;
  15. bool verbose = false;
  16. int status = readMinitaurLogFile(fileName, structNames, structTypes, logRecords, verbose);
  17. for (int i = 0; i < logRecords.size(); i++)
  18. {
  19. for (int j = 0; j < structTypes.size(); j++)
  20. {
  21. switch (structTypes[j])
  22. {
  23. case 'I':
  24. {
  25. int v = logRecords[i].m_values[j].m_intVal;
  26. printf("record %d, %s = %d\n", i, structNames[j].c_str(), v);
  27. break;
  28. }
  29. case 'f':
  30. {
  31. float v = logRecords[i].m_values[j].m_floatVal;
  32. printf("record %d, %s = %f\n", i, structNames[j].c_str(), v);
  33. break;
  34. }
  35. case 'B':
  36. {
  37. int v = logRecords[i].m_values[j].m_charVal;
  38. printf("record %d, %s = %d\n", i, structNames[j].c_str(), v);
  39. break;
  40. }
  41. default:
  42. {
  43. }
  44. }
  45. }
  46. }
  47. }
  48. #ifdef ENABLE_GTEST
  49. TEST(RobotLoggingTest, LogMinitaur)
  50. {
  51. testMinitaurLogging();
  52. }
  53. #endif
  54. int main(int argc, char* argv[])
  55. {
  56. //b3SetCustomPrintfFunc(myprintf);
  57. //b3SetCustomWarningMessageFunc(myprintf);
  58. #ifdef ENABLE_GTEST
  59. #if _MSC_VER
  60. _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
  61. //void *testWhetherMemoryLeakDetectionWorks = malloc(1);
  62. #endif
  63. ::testing::InitGoogleTest(&argc, argv);
  64. return RUN_ALL_TESTS();
  65. #else
  66. testMinitaurLogging();
  67. #endif
  68. }