Boost documentation simple example fails

I know I must be doing something wrong. I am trying to use the very simple example at: http://www.boost.org/doc/libs/1_43_0/libs/test/doc/html/tutorials/hello-the-... #include <my_class.hpp> #define BOOST_TEST_MODULE MyTest #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE( my_test ) { my_class test_object( "qwerty" ); BOOST_CHECK( test_object.is_valid() ); } I constructed and compiled a very simple class to use, but I get a compile error using the simple test above. I am using gcc version 4.1.2 on SUSE_linux. The compile error I get is: test_my_class.cpp:5: error: expected constructor, destructor, or type conversion before '(' token It is as if the compiler does not recognize BOOST_AUTO_TEST_CASE. Here is the my_class.hpp file: //==================== #include <string> using namespace std; class my_class { public: my_class( string str ); ~my_class(); private: bool valid; public: bool is_valid(); }; Here is my_class.cpp file: //==================== #include "my_class.hpp" my_class::my_class( string str ) { valid = false; } my_class::~my_class() { } bool my_class::is_valid() { return valid; } I may have made some typos while entering this code, but it does compile, and it does function properly when I instantiate it with another test program. What am I doing wrong? Thanks, Herb Miller

<hmiller <at> hiwaay.net> writes:
#include <my_class.hpp> #define BOOST_TEST_MODULE MyTest #include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE( my_test ) ... test_my_class.cpp:5: error: expected constructor, destructor, or type conversion before '(' token
Try: 1. move your include after boost.Test 2. Produce preprocessor output. See what is on line 5 Gennadiy

AMDG hmiller@hiwaay.net wrote:
I know I must be doing something wrong. I am trying to use the very simple example at: http://www.boost.org/doc/libs/1_43_0/libs/test/doc/html/tutorials/hello-the-...
#include <my_class.hpp> #define BOOST_TEST_MODULE MyTest #include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE( my_test ) { my_class test_object( "qwerty" );
BOOST_CHECK( test_object.is_valid() ); }
I constructed and compiled a very simple class to use, but I get a compile error using the simple test above. I am using gcc version 4.1.2 on SUSE_linux. The compile error I get is:
test_my_class.cpp:5: error: expected constructor, destructor, or type conversion before '(' token
It is as if the compiler does not recognize BOOST_AUTO_TEST_CASE. <snip>
If you're using an old version of the test library (I don't remember exactly when the cutoff is), you need #include <boost/test/test_tools.hpp> In Christ, Steven Watanabe

I think the whole problem is related to the version. I am new to the project I am working on, and their version of Boost is 1.33.1. I have been able to get some other things to work under that version. Thanks for the help. Herb Miller Quoting "Steven Watanabe" <watanabesj@gmail.com>:
AMDG
hmiller@hiwaay.net wrote:
I know I must be doing something wrong. I am trying to use the very simple example at: http://www.boost.org/doc/libs/1_43_0/libs/test/doc/html/tutorials/hello-the-... #include <my_class.hpp> #define BOOST_TEST_MODULE MyTest #include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE( my_test ) { my_class test_object( "qwerty" );
BOOST_CHECK( test_object.is_valid() ); }
I constructed and compiled a very simple class to use, but I get a compile error using the simple test above. I am using gcc version 4.1.2 on SUSE_linux. The compile error I get is:
test_my_class.cpp:5: error: expected constructor, destructor, or type conversion before '(' token
It is as if the compiler does not recognize BOOST_AUTO_TEST_CASE. <snip>
If you're using an old version of the test library (I don't remember exactly when the cutoff is), you need #include <boost/test/test_tools.hpp>
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Gennadiy Rozental
-
hmiller@hiwaay.net
-
Steven Watanabe