title: Boost Unit Testing and Visual Studio 2005/Visual C++ and the BOOST_AUTO_TEST_SUITE(stringtest) namespace?
body: <p>I'm reading <a href="http://www.ibm.com/developerworks/aix/library/au-ctools1_boost/?S_TACT=105AGY20&amp;S_CMP=HP" rel="nofollow noreferrer">this article</a> on the Boost Unit Testing Framework.</p>
  
  <p>However I'm having a bit of trouble with the first example, my guess is that they left something out (something that would be obvious to hardcore C++ coders) as IBM often does in their articles.  Another possibility is that my Visual Studio 2005 C++ compiler is just too old for the example.</p>
  
  <pre><code>#include "stdafx.h"
  #define BOOST_TEST_MODULE stringtest
  #include &lt;boost/test/unit_test.hpp&gt;
  //#include "mystring.h"
  
  BOOST_AUTO_TEST_SUITE(stringtest) // name of the test suite is stringtest
  
  BOOST_AUTO_TEST_CASE(test1)
  {
    /*
    mystring s;
    BOOST_CHECK(s.size() == 0);
    */
    BOOST_CHECK(0 == 0);
  }
  
  BOOST_AUTO_TEST_CASE(test2)
  {
    /*
    mystring s;
    s.setbuffer("hello world");
    BOOST_REQUIRE_EQUAL('h', s[0]); // basic test
    */
     BOOST_CHECK(0 == 0);
  }
  
  BOOST_AUTO_TEST_SUITE_END()
  </code></pre>
  
  <p>To me the BOOST_AUTO_TEST_SUITE and BOOST_AUTO_TEST_CASE lines look a little suspect (especially since they don't have quotes around the arguments, and they are undeclared identifiers...but this probably means they are macros and I'm not certain I understand the concept or if that is available in VC++ 8.0)...</p>
  
  <pre><code>#ifdef _MYSTRING
  #define _MYSTRING
  
  class mystring {
     char* buffer;
     int length;
     public:
        void setbuffer(char* s) { buffer s = s; length = strlen(s); }
        char&amp; operator[ ] (const int index) { return buffer[index]; }
        int size() {return length; }
  }
  
  #endif
  </code></pre>
  
  <p>Is there any reason why this code won't work?</p>
  
  <pre><code>1&gt;c:\users\andy\documents\visual studio 2005\projects\unittesttests\unittesttests\unittesttests.cpp(7) : error C2065: 'stringtest' : undeclared identifier
  1&gt;c:\users\andy\documents\visual studio 2005\projects\unittesttests\unittesttests\unittesttests.cpp(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  1&gt;c:\users\andy\documents\visual studio 2005\projects\unittesttests\unittesttests\unittesttests.cpp(9) : error C2146: syntax error : missing ';' before identifier 'BOOST_AUTO_TEST_CASE'
  1&gt;c:\users\andy\documents\visual studio 2005\projects\unittesttests\unittesttests\unittesttests.cpp(9) : error C2065: 'test1' : undeclared identifier
  1&gt;c:\users\andy\documents\visual studio 2005\projects\unittesttests\unittesttests\unittesttests.cpp(10) : error C2448: 'BOOST_AUTO_TEST_CASE' : function-style initializer appears to be a function definition
  1&gt;c:\users\andy\documents\visual studio 2005\projects\unittesttests\unittesttests\unittesttests.cpp(18) : error C2065: 'test2' : undeclared identifier
  1&gt;c:\users\andy\documents\visual studio 2005\projects\unittesttests\unittesttests\unittesttests.cpp(19) : error C2448: 'BOOST_AUTO_TEST_CASE' : function-style initializer appears to be a function definition
  1&gt;c:\users\andy\documents\visual studio 2005\projects\unittesttests\unittesttests\unittesttests.cpp(29) : fatal error C1004: unexpected end-of-file found
  </code></pre>