Boost library question

Hi Guys,

1
2
3
4
5
6
7
8
9
10
11
12
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE Hello
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>

BOOST_AUTO_TEST_CASE(addFunctionTest) {
//    BOOST_CHECK(add(2,2) == 4) ; 
    int col1 [] = { 1, 2, 3, 4, 5, 6, 7 };
    int col2 [] = { 1, 2, 4, 4, 5, 7, 7 };
    BOOST_CHECK_EQUAL_COLLECTIONS(col1,col1+7,col2) ; 
}



g++ -Wall -lboost_unit_test_framework -o hello hello.cpp boostTest.cpp
boostTest.cpp:11:51: error: macro "BOOST_CHECK_EQUAL_COLLECTIONS" requires 4 arguments, but only 3 given
boostTest.cpp: In member function ‘void addFunctionTest::test_method()’:
boostTest.cpp:11: error: ‘BOOST_CHECK_EQUAL_COLLECTIONS’ was not declared in this scope




I have checked test/test_tools.hpp file and BOOST_CHECK_EQUAL_COLLECTIONS is defined under it. Can anyone please tell me what am I doing wrong in this?

I am using ubuntu9.10

Thanks
Start with the first error and then worry about the second one. ;)

From boost/test/test/tools.hpp:
1
2
#define BOOST_CHECK_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end )         \
    BOOST_EQUAL_COLLECTIONS_IMPL( L_begin, L_end, R_begin, R_end, CHECK ) 
Last edited on
I swear to God I saw BOOST_CHECK_EQUAL_COLLECTIONS(L_begin, R_begin, R_BEGIN)

http://www.boost.org/doc/libs/1_31_0/libs/test/doc/components/test_tools/reference/BOOST_CHECK_EQUAL_COLLECTIONS.html

But your method works. Thanks a lot moorecm
I can't seem to locate that example for 1.41.0 (which is the version I quoted above); it may have changed since 1.31.0. Just out of curiosity, may I ask what version you're actually using?
Last edited on
I just checked the version that I am using is 1.40 and that clearly explains what I was doing wrong. Could you please tell me from where to check the version specific documentation?

Thanks
Thanks moorecm
Hi guys. I'm new here.
I have a problem with boost::program_options
I have an option "password,p" (--password || -p)
this option is supposed to be able to accept the password (not recommended) via command line and if the option is empty (myprog -v -p -o file) then it should be added to the vector<string> as "" (empty) because multiple passwords can be defined (myprog -v -p pass1 pass2 -p -o file) but when i get to a -p that is without an value. regarless of whether I use implicit_value(vector<string>(1,"")) or default_value(..) it replaces the entire vector with the value I gave it. is there a way to have it added to the vector ?
Topic archived. No new replies allowed.