|
Boost Users : |
Subject: [Boost-users] [BOOST]BOOST_AUTO_TEST_CASE_TEMPLATE vs BOOST_AUTO_TEST_CASE
From: Hemanth Choudary M V (RBEI/ETA1) (HemanthChoudary.MV_at_[hidden])
Date: 2013-09-18 01:35:39
Hi,
Scenario1:
Both files are present in the same Project BoostUnitTest.
fileA:
typedef boost::mpl::list<long long,unsigned char> test_types;
BOOST_AUTO_TEST_SUITE(MySuite)
BOOST_AUTO_TEST_CASE_TEMPLATE( my_test, T, test_types )
{
BOOST_CHECK_EQUAL( sizeof(T), (unsigned)4 );
}
BOOST_AUTO_TEST_SUITE_END()
fileB:
typedef boost::mpl::list<long long,unsigned char> test_types;
BOOST_AUTO_TEST_SUITE(MySuite)
BOOST_AUTO_TEST_CASE_TEMPLATE( my_test, T, test_types )
{
BOOST_CHECK_EQUAL( sizeof(T), (unsigned)4 );
}
BOOST_AUTO_TEST_SUITE_END()
As shown above, MySuite is extended across 2 files fileA and fileB. The BOOST_AUTO_TEST_CASE_TEMPLATE name is same across the both the files and and the suite name is also same across both the files..
Boost is able to differentiate between the 2 test cases and the test cases are executed.
Scenario2:
fileA:
BOOST_AUTO_TEST_SUITE(MySuite)
BOOST_AUTO_TEST_CASE( my_test)
{
BOOST_CHECK_EQUAL(1,1);
}
BOOST_AUTO_TEST_SUITE_END()
fileB:
BOOST_AUTO_TEST_SUITE(MySuite)
BOOST_AUTO_TEST_CASE_TEMPLATE( my_test )
{
BOOST_CHECK_EQUAL( 1,1 );
}
BOOST_AUTO_TEST_SUITE_END()
In the scenario2, I get a compile time error (Error 1 error LNK2005: "public: void __thiscall mySuite::insuite2::test_method(void)" (?test_method_at_insuite2@mySuite@@QAEXXZ) already defined in BoostUnitTest.obj) which basically suggests that one or more multiply defined symbols are found.
Why is the behaviour different in these 2 scenarios? How is Boost able to differenciate between the 2 test cases in Scenario1?
Mit freundlichen Grüßen / Best Regards,
Hemanth Choudary MV
RBEI/ETA1
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