mardi 23 février 2016

HOWTO start unit testing with boost C++

I have the following basic test in file:

//test.cpp
#define BOOST_TEST_MODULE test_module_name
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(first_test)
{
    int i = 1;
    BOOST_TEST(i); 
    BOOST_TEST(i == 2); 
}

Compiling and linking using gcc

gcc -L usr/local/lib/ -I usr/local/include/ \
    -c test/test.cpp -lboost_unit_test_framework \
    -lboost_test_exec_monitor -o build/test.out

When I run test.out I get the following error

bash: ./test.out: cannot execute binary file: Exec format error

I believe this issue may have something to do with the fact that this file has no main function, this is because I am expecting test exec monitor to run this test and this is not happening.

Q1) Can I get a detailed HOWTO do a basic unit test with boost

or

Q2) What is required for exec monitor to run these tests?

Aucun commentaire:

Enregistrer un commentaire