Menu

Assert with map(STL)

Help
ritesh
2003-01-22
2003-01-22
  • ritesh

    ritesh - 2003-01-22

    Hi
         pls tell me can i use CPPUNIT_ASSERT or CPPUNITASSERT_EQUAL to compare the to maps.
    because with this CPPUNIT_ASSERT ia m getting 15 error
    d:\program files\microsoft visual studio\vc98\include\utility(31) : error C2784: 'bool __cdecl std::operator ==(const class std::vector<_Ty,_A> &,const class std::vector<_Ty,_A> &)' : could not deduce template argument for 'const class std::vector<_
    Ty,_A> &' from 'const class CCLPoption'
            d:\program files\microsoft visual studio\vc98\include\xutility(88) : see reference to function template instantiation 'bool __cdecl std::operator ==(const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std:
    :allocator<char> > const ,class CCLPoption> &,const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class CCLPoption> &)' being compiled

    and if using CPPUNIT_ASSERT_EQUAL() then it is giving error there

    :\cppunit-1.8.0\include\cppunit\testassert.h(45) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'const class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
    ,class CCLPoption,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class CCLPoption> >' (or there is no acceptable conversion)
            c:\cppunit-1.8.0\include\cppunit\testassert.h(43) : while compiling class-template member function 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CppUnit::assertion_traits<class std::map<clas
    s std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class CCLPoption,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<class CCLPoption> >
    >::toString(const class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class CCLPoption,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,clas
    s std::allocator<class CCLPoption> > &)'
    Error executing cl.exe.

    CLPinputHolderTest.obj - 1 error(s), 0 warning(s)

    Pls Look in to it i think i have to use CPPUNIT_ASSERT only.

    But if i am wrong any where pls tell me..

    Regards

    - Ritesh

     
    • Tom Plunket

      Tom Plunket - 2003-01-22

      Reading the error messages carefully, you'll see that it can't figure out how to compile operator== for your CCLPoption class (did you forget to write it?) for the vectors, and it doesn't know how to create operator<< for the mapsto write them to the output stream.  You should use CPPUNIT_ASSERT(map1 == map2) and implement bool operator==(const CCLPoption&, const CCLPoption&);

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.