Main.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "UnitTestPCH.h"
  2. //#include <cppunit/XMLOutputter.h>
  3. #include <cppunit/CompilerOutputter.h>
  4. #include <cppunit/extensions/TestFactoryRegistry.h>
  5. #include <cppunit/TestResult.h>
  6. #include <cppunit/TestResultCollector.h>
  7. #include <cppunit/TestRunner.h>
  8. #include <cppunit/BriefTestProgressListener.h>
  9. #include <math.h>
  10. #include <time.h>
  11. int main (int argc, char* argv[])
  12. {
  13. // seed the randomizer with the current system time
  14. time_t t;time(&t);
  15. srand((unsigned int)t);
  16. // ............................................................................
  17. // create a logger from both CPP
  18. Assimp::DefaultLogger::create("AssimpLog_Cpp.txt",Assimp::Logger::VERBOSE,
  19. aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE);
  20. // .. and C. They should smoothly work together
  21. aiEnableVerboseLogging(AI_TRUE);
  22. aiLogStream logstream= aiGetPredefinedLogStream(aiDefaultLogStream_FILE, "AssimpLog_C.txt");
  23. aiAttachLogStream(&logstream);
  24. // ............................................................................
  25. // Informiert Test-Listener ueber Testresultate
  26. CPPUNIT_NS :: TestResult testresult;
  27. // Listener zum Sammeln der Testergebnisse registrieren
  28. CPPUNIT_NS :: TestResultCollector collectedresults;
  29. testresult.addListener (&collectedresults);
  30. // Listener zur Ausgabe der Ergebnisse einzelner Tests
  31. CPPUNIT_NS :: BriefTestProgressListener progress;
  32. testresult.addListener (&progress);
  33. // Test-Suite ueber die Registry im Test-Runner einfuegen
  34. CPPUNIT_NS :: TestRunner testrunner;
  35. testrunner.addTest (CPPUNIT_NS :: TestFactoryRegistry :: getRegistry ().makeTest ());
  36. testrunner.run (testresult);
  37. // Resultate im Compiler-Format ausgeben
  38. CPPUNIT_NS :: CompilerOutputter compileroutputter (&collectedresults, std::cerr);
  39. compileroutputter.write ();
  40. #if 0
  41. // Resultate im XML-Format ausgeben
  42. std::ofstream of("output.xml");
  43. CPPUNIT_NS :: XmlOutputter xml (&collectedresults, of);
  44. xml.write ();
  45. #endif
  46. // ............................................................................
  47. // but shutdown must be done from C to ensure proper deallocation
  48. aiDetachAllLogStreams();
  49. // Rueckmeldung, ob Tests erfolgreich waren
  50. return collectedresults.wasSuccessful () ? 0 : 1;
  51. }