Boost logo

Boost Users :

Subject: Re: [Boost-users] Syntax error when using BOOST_CHECK_PREDICATE
From: Andrew J. Leer (leeand00_at_[hidden])
Date: 2010-02-23 14:14:18


Here is my example:

#include "stdafx.h"
#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

std::list<int>* user_defined_func( ) {
        std::cout << "BEGIN: user_defined_func" << std::endl;
        std::list<int>* l = new std::list<int>;

        l->push_back(8);
        l->push_back(0);

        std::cout << "END: user_defined_func" << std::endl;

        return l;
}

bool validate_list(std::list<int> &L1)
{

   std::cout << "BEGIN: validate_list" << std::endl;

   std::list<int>::iterator it1 = L1.begin();

   for(; it1 != L1.end(); ++it1)
   {
      if(*it1<= 1){

             std::cout << "Validation failed because an item in the list was
less than or equal to 1." << std::endl;
                 std::cout << "END: validate_list" << std::endl;
         return false;
       }
   }

   std::cout << "Test passed because all of the items in the list were
greater than or equal to 1" << std::endl;
   std::cout << "END: validate_list" << std::endl;
  return true;
}

BOOST_AUTO_TEST_SUITE( test )
BOOST_AUTO_TEST_CASE( test )
{
   std::list<int>* list1 = user_defined_func();
   BOOST_CHECK_PREDICATE( validate_list, (list1) );
}
BOOST_AUTO_TEST_SUITE_END()

Thank you,
   Andrew J. Leer

On Sun, Jan 3, 2010 at 8:00 PM, Gennadiy Rozental <rogeeff_at_[hidden]> wrote:
> Andrew J. Leer wrote:
>>
>> Gennadiy,
>>    I tried changing what you stated
>>
>>>> BOOST_AUTO_TEST_CASE( test )
>>>> {
>>>>   std::list<int>& list1 = user_defined_func();
>>>>   BOOST_CHECK_PREDICATE( validate_list, list1 );
>>
>>> I believe this should be
>>> BOOST_CHECK_PREDICATE( validate_list, (list1) );
>>
>> However upon doing that I get another error (something to do with
>> templates)
>
> Please post small example illustrating the problem.
>
> Gennadiy
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net