Boost logo

Boost Users :

Subject: [Boost-users] [Test] Problem with expected failures in test suite
From: Maria Kozinska (maria.kozinska_at_[hidden])
Date: 2010-06-03 09:37:08


Hello,

I tried to write a test suite with one expected failure, however it is
not working. Probably I'm doing something wrong.
The idea is that I have a function that can be implemented in few
ways, thus there are few possible correct results. Depending on the
implementation, I want to test it with different set of test cases. I
don't want to check at the beginning of each test case which option is
valid, I would prefer to skip unnecessary test cases. Is it possible?

The simplified code is below:

bool xxx = ...;

// opt1 and opt2: two exclusive options
// one of them always passes and one always fails
void opt1(){
    BOOST_CHECK(xxx);
}
void opt2(){
    BOOST_CHECK(!xxx);
}

void test1_1(){
}

test_suite*
init_unit_test_suite( int argc, char* argv[] ) {
    test_case* opt1_case = BOOST_TEST_CASE(&opt1);
    test_case* opt2_case = BOOST_TEST_CASE(&opt2);

    test_suite* dichotomic_test = BOOST_TEST_SUITE( "dichotomic test" );
    framework::master_test_suite().add(dichotomic_test);

    dichotomic_test->add( opt1_case );
    dichotomic_test->add( opt2_case );
    // I want exactly one of them to fail
    dichotomic_test->increase_exp_fail(1);

    test_case* case1_1 = BOOST_TEST_CASE(&test1_1);

    case1_1->depends_on(opt1_case);
    framework::master_test_suite().add(case1_1);
}

I'll be thankful for help,
Maria


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