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-24 12:23:21


Okay here's the new source, thanks Gennadiy for your time on this.

#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(2);

        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)
   {
           std::cout << "*it1: " << *it1 << std::endl;

      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) );
   delete list1;
}
BOOST_AUTO_TEST_SUITE_END()

On Tue, Feb 23, 2010 at 5:09 PM, Gennadiy Rozental <rogeeff_at_[hidden]> wrote:
> Andrew J. Leer <leeand00 <at> hotmail.com> writes:
>
>> bool validate_list(std::list<int> &L1)
> ...
>
>> 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()
>
> No surprises here: can't pass pointer to the function expecting reference.
>
> 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