Hi,
I'm having a bit of trouble getting user-defined objects working with Boost.Test. I skimmed through the docs and I didn't see anything on this subject, but the boost documentation isn't the most intuitive documentation, so it is a bit easy to miss obvious stuff like this.
Anyway, I have a class named "Foo", and I've given it an overloaded boolean == operator. When I do the following, it fails to compile under MSVC9:
Foo a, b;
BOOST_TEST_EQUAL( a, b );
The class is defined as follows:
class Foo
{
private:
std::string data;
public:
Foo()
: data( "Testing 123" )
{}
Foo( Foo const& other )
{
data = other.data;
}
bool operator== ( Foo const& operand )
{
return data == operand.data;
}
};
Below is the error I'm getting. How can I make this work? I've truncated it a little bit since it's insanely long:
1>c:\it\tfs\crusades\sdks\boost\boost\test\test_tools.hpp(342) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const Foo' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)' [found using argument-dependent lookup]
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(700): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)' [found using argument-dependent lookup]
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(738): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)' [found using argument-dependent lookup]
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]