00001 //---------------------------------------------------------------------------- 00002 /** @file TestMain.cpp 00003 */ 00004 //---------------------------------------------------------------------------- 00005 00006 #include <cstdlib> 00007 #include <boost/version.hpp> 00008 00009 #include "config.h" 00010 #include "HexProgram.hpp" 00011 00012 using namespace benzene; 00013 00014 #define BOOST_VERSION_MAJOR (BOOST_VERSION / 100000) 00015 #define BOOST_VERSION_MINOR (BOOST_VERSION / 100 % 1000) 00016 00017 //---------------------------------------------------------------------------- 00018 00019 namespace { 00020 00021 /** Initializes hex system. */ 00022 void Initialize() 00023 { 00024 int argc = 1; 00025 char name[] = "bin/hex-test"; 00026 char* argv = name; 00027 HexProgram& program = HexProgram::Get(); 00028 program.SetInfo("hex-test", VERSION, __DATE__); 00029 program.Initialize(argc, &argv); 00030 } 00031 00032 } // namespace 00033 00034 //---------------------------------------------------------------------------- 00035 00036 #if BOOST_VERSION_MAJOR == 1 && BOOST_VERSION_MINOR == 32 00037 00038 #include <boost/test/auto_unit_test.hpp> 00039 boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) 00040 { 00041 Initialize(); 00042 return boost::unit_test::ut_detail::auto_unit_test_suite(); 00043 } 00044 00045 //---------------------------------------------------------------------------- 00046 00047 #elif BOOST_VERSION_MAJOR == 1 && BOOST_VERSION_MINOR == 33 00048 00049 #include <boost/test/auto_unit_test.hpp> 00050 boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) 00051 { 00052 UNUSED(argc); 00053 UNUSED(argv); 00054 Initialize(); 00055 return boost::unit_test::auto_unit_test_suite(); 00056 } 00057 00058 //---------------------------------------------------------------------------- 00059 00060 #elif BOOST_VERSION_MAJOR == 1 && BOOST_VERSION_MINOR >= 34 00061 00062 // Shamelessly copied from Fuego. :) 00063 00064 // Handling of unit testing framework initialization is messy and not 00065 // documented in the Boost 1.34 documentation. See also: 00066 // http://lists.boost.org/Archives/boost/2006/11/112946.php 00067 00068 #define BOOST_TEST_DYN_LINK // Must be defined before including unit_test.hpp 00069 #include <boost/test/unit_test.hpp> 00070 00071 bool init_unit_test() 00072 { 00073 Initialize(); 00074 return true; 00075 } 00076 00077 int main(int argc, char** argv) 00078 { 00079 return boost::unit_test::unit_test_main(&init_unit_test, argc, argv); 00080 } 00081 00082 //---------------------------------------------------------------------------- 00083 00084 #else 00085 #error "Unknown Boost version!" 00086 #endif 00087 00088 //----------------------------------------------------------------------------