I want to start to use Boost Test library to create tests for my application.
Following the tutorial that I've found at http://www.boost.org/doc/libs/1_47_0/libs/test/doc/html/tutorials/new-year-resolution.html I've started my test class.
So, I've created a class for my test, and the simple .cpp is this one
#define BOOST_TEST_MODULE MyClass test
#include <boost/test/unit_test.hpp>
#include "myclasstest.h"
MyClassTest::MyClassTest()
{
}
/**
* Test the class.
*/
bool MyClassTest::testClass()
{
BOOST_AUTO_TEST_CASE(empty_test)
{
MyClass xTest;
BOOST_CHECK(xTest.isEmpty());
}
return true;
}
Ok, I know that I must do something more intelligent than return true, but it' not the problem. The problem is that it does not compile. I think that library is corrected loaded, because If I compile only with first two rows I've no error, as explained in the tutorial page.
If I try to compile it, I obtain this error output from GCC:
myclasstest.cpp: In member function ‘bool MyClassTest::testClass()’:
myclasstest.cpp:16:5: error: a function-definition is not allowed here before ‘{’ token
myclasstest.cpp:16:1: error: ‘empty_test_invoker’ was not declared in this scope
myclasstest.cpp:16:5: error: template argument for ‘template<class T> struct boost::unit_test::ut_detail::auto_tc_exp_fail’ uses local type ‘MyClassTest::testClass()::empty_test_id’
myclasstest.cpp:16:5: error: trying to instantiate ‘template<class T> struct boost::unit_test::ut_detail::auto_tc_exp_fail’
myclasstest.cpp:17:5: error: a function-definition is not allowed here before ‘{’ token
myclasstest.cpp:23:1: error: expected ‘}’ at end of input
myclasstest.cpp:23:1: warning: no return statement in function returning non-void
I'm new to Boost, so I don't know what I must do. What I'm doing wrong? I think that I've done the same steps of tutorial, or not?
Thanks for your replies.