简体   繁体   中英

Boost Unit testing with Allegro Graphics Library

I'm trying to use boost unit testing alongside the Allegro graphics library, but both require main() alterations / overwrites. Has anyone had any experience using both?

Edit 1/29/2010: I've refrained from selecting an answer until I can verify one or another, and due to the... sparse nature of the answers.

boost.test can be used with or without a main(). look into these macros will give you some idea how to use it properly:

//#define BOOST_TEST_MODULE my_test
//#define BOOST_TEST_MAIN
//#define BOOST_TEST_DYN_LINK
//#define BOOST_TEST_NO_MAIN

I don't quite see the issue, you do the boost functions you want to run inside of main, the allegro setup, then run your tests, do the allegro teardown, whatever of boost you want to tear down.

Unless you want to unit test the allegro setup functions there should not be a problem.

Can you clarify or post specific problems ?

I had a similar problem with qt, here is teh code that worked for me on boost 1_44 using the shared library

//Testing the lib

//###################################################################################
//Setting up boost testing framework
#define BOOST_TEST_NO_MAIN
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "Unit test for libcommon"

#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
//###################################################################################

#include <QApplication>
#include <QtGui>

using namespace boost::unit_test;

int main(int argc, char *argv[]) {
  (void) argc;
  (void) argv;

  QApplication app(argc, argv);
  QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));

  ::boost::unit_test::unit_test_main( &init_unit_test, argc, argv );

  return app.exec();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM