Boost logo

Boost :

From: Chad Maron (cmaron_at_[hidden])
Date: 2007-05-16 07:09:19


I know the error has nothing to do with BOOST_PARAM_TEST_CASE, just like I mentioned in the sentence immediately following the error. I mention BOOST_PARAM_TEST_CASE because that is the where I found code to use to prevent the parameters from being destroyed until the test case is run. I also know the reason for the error, my question is what is the new technique for 1.34.

"The user should make sure that parameters list will not be destroyed until the test case is run. That's why it not recommended to create a parameters list as local variable in init_unit_test_suite. A simple way to handle a parameters list lifetime is to place it into a user defined test suite class." - http://www.boost.org/libs/test/doc/components/utf/components/test_case/param_function_tc.html

Again, I know this won't work in 1.34... but what will? *IS* there a new simple method for this in 1.34? How much code will I have to modify to get my tests to work with the new version?

Here is an example code modeled after the examples from http://www.boost.org/libs/test/doc/components/utf/components/test_case/param_function_tc.html and http://www.boost.org/libs/test/doc/components/utf/components/test_case/param_boost_function_tc.html

-----
#include <iostream>
#include <map>
#include <string>

#include <boost/shared_ptr.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/parameterized_test.hpp>
#include <boost/test/included/unit_test_framework.hpp>

using boost::unit_test::test_suite;

void parse_test(std::string str) {
    BOOST_CHECK(1);
}

struct sub_test_suite : public boost::unit_test::test_suite {
    sub_test_suite() {
        while(std::cin) {
            getline(std::cin, input_line);
            if(input_line.size() > 0) {
                queries.push_back(input_line);
            }
        }
        add( BOOST_PARAM_TEST_CASE( &parse_test, queries.begin(), queries.end() ), 0 );
    }
    std::string input_line;
    std::vector<std::string> queries;
};

test_suite*
init_unit_test_suite( int, char* [] ) {
    test_suite* test= BOOST_TEST_SUITE( "Spirit SQL parser" );

    test->add(new sub_test_suite());

    return test;
}

-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Gennadiy Rozental
Sent: Wednesday, May 16, 2007 2:44 AM
To: boost_at_[hidden]
Subject: Re: [boost] Boost 1.34 Unit test suite - BOOST_PARAM_TEST_CASE

"Chad Maron" <cmaron_at_[hidden]> wrote in message
news:82DA1BC8E3377840AAC2B22ACFAB1EE437FD4CF5_at_exchange3.corp.logicworks.net...
> Hey all,
>
> I have some code that is essentially doing what is suggested on the
> Parameterized free function based test case page
> (http://www.boost.org/libs/test/doc/components/utf/components/test_case/param_function_tc.html).
>
> This technique worked fine in 1.33.1 but in 1.34 I get the following error
> when I try to compile my test:
>
> Test.cpp: In constructor
> 'sub_test_suite::sub_test_suite(boost::shared_ptr<Tester>)':
> Test.cpp:98: error: no matching function for call to
> 'boost::unit_test::test_suite::test_suite()'
> /usr/local/include/boost-1_34/boost/test/impl/unit_test_suite.ipp:110:
> note: candidates are:
> boost::unit_test::test_suite::test_suite(boost::unit_test::const_string)
> /usr/local/include/boost-1_34/boost/test/unit_test_suite_impl.hpp:116:
> note: boost::unit_test::test_suite::test_suite(const
> boost::unit_test::test_suite&)

Above error has nothing to do with BOOST_PARAM_TEST_CASE

> I understand the reason for the error but I am not sure about what to do

The reason is that test_suite is not default constractible.

> . Is there a new technique for using BOOST_PARAM_TEST_CASE to ensure the
> parameters are not destroyed until the test case is run?

Please provide a simple examples that fails.

Genandiy

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk