Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // breakboost.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #define BOOST_TEST_MODULE SVGADTCT_TEST
- #define BOOST_TEST_NO_MAIN
- #ifdef BOOST_TEST_MODULE
- #include <boost/test/included/unit_test.hpp>
- using namespace boost::unit_test;
- //BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE);
- //BOOST_AUTO_TEST_SUITE_END()
- int TestMain(); // In this situation there is a separate TestMain() from WinMain()
- bool TestInit(); // Create stub initialization function for Boost.
- bool TestInit()
- {
- //- Register test
- framework::master_test_suite().add( BOOST_TEST_CASE(TestMain) );
- return true;
- };
- #endif
- /*
- * Prototypes --
- */
- static void Log(const char *fmt, ...);
- int _tmain(int argc, _TCHAR* argv[])
- {
- #ifdef BOOST_TEST_MODULE
- //- Call test framework
- ::boost::unit_test::unit_test_main( (boost::unit_test::init_unit_test_func) TestInit , __argc, __argv );
- return 0;
- } // _tmain
- int TestMain()
- {
- #endif //BOOST_TEST_MODULE
- Log("INFO, starting. \n");
- Log("INFO, exit.\n");
- return 0;
- } //TestMain()
- void
- Log(const char *fmt, ...)
- {
- time_t timet;
- struct tm stime;
- char buffer[32];
- va_list args;
- static FILE *logFile = NULL;
- if (!logFile) {
- fopen_s(&logFile, "svgadtct.log", "w");
- }
- time(&timet);
- localtime_s(&stime, &timet);
- asctime_s(buffer, &stime);
- buffer[24] = 0; // clobber the newline at the end of the date
- fprintf(logFile, "%s: TEST| ", buffer);
- va_start(args, fmt);
- vfprintf(logFile, fmt, args);
- char myOutputBuffer[1000] = {0};
- _snprintf_s(myOutputBuffer,(size_t) 999, fmt, args);
- if ( strstr(myOutputBuffer, "WARN") )
- {
- BOOST_WARN_MESSAGE(1, myOutputBuffer);
- }
- else if ( strstr(myOutputBuffer, "FAIL") )
- {
- BOOST_CHECK_MESSAGE(1, myOutputBuffer);
- }
- else //Everything else Plus ERROR
- {
- //-- Normally for ERROR would ask BOOST to abort by failing REQUIRE().
- // Will let program handle control flow change since all ERROR conditions
- // are properly handled by this framework.
- BOOST_WARN_MESSAGE(1, myOutputBuffer);
- }
- va_end(args);
- fflush(logFile);
- } // Log()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement