-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
- clashing on name only - adding tests
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,6 +241,14 @@ test_suite::test_suite( const_string module_name ) | |
void | ||
test_suite::add( test_unit* tu, counter_t expected_failures, unsigned timeout ) | ||
{ | ||
// check for clashing names #12597 | ||
for( test_unit_id_list::const_iterator it(m_children.begin()), ite(m_children.end()); | ||
it < ite; | ||
++it) { | ||
BOOST_TEST_SETUP_ASSERT( tu->p_name != framework::get(*it, TUT_ANY).p_name, | ||
"test unit with name '" + tu->p_name.value + std::string("' registered multiple times") ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
raffienficiaud
Author
Member
|
||
} | ||
|
||
tu->p_timeout.value = timeout; | ||
|
||
m_children.push_back( tu->p_id ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// (C) Copyright Raffi Enficiaud 2018. | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
// See http://www.boost.org/libs/test for the library home page. | ||
// | ||
//! @file | ||
//! checking the clashing names, ticket trac #12597 | ||
// ***************************************************************************** | ||
|
||
#define BOOST_TEST_MODULE test_clashing_names | ||
#include <boost/test/unit_test.hpp> | ||
#include <boost/mpl/list.hpp> | ||
|
||
void suite1_test1() | ||
{ | ||
BOOST_CHECK(true); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE( test_clashing_suites ) | ||
{ | ||
using namespace boost::unit_test; | ||
test_suite* master_ts = BOOST_TEST_SUITE("local master"); | ||
test_suite* t_suite1 = BOOST_TEST_SUITE( "suite1" ); | ||
test_suite* t_suite2 = BOOST_TEST_SUITE( "suite1" ); | ||
master_ts->add(t_suite1); | ||
BOOST_CHECK_THROW( master_ts->add(t_suite2), | ||
boost::unit_test::framework::setup_error ); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE( test_clashing_cases ) | ||
{ | ||
using namespace boost::unit_test; | ||
test_suite* master_ts = BOOST_TEST_SUITE("local master"); | ||
test_suite* t_suite1 = BOOST_TEST_SUITE( "suite1" ); | ||
test_suite* t_suite2 = BOOST_TEST_SUITE( "suite2" ); | ||
master_ts->add(t_suite1); | ||
master_ts->add(t_suite2); | ||
|
||
t_suite1->add( BOOST_TEST_CASE( suite1_test1 ) ); | ||
BOOST_CHECK_THROW( t_suite1->add( BOOST_TEST_CASE( suite1_test1 ) ), | ||
boost::unit_test::framework::setup_error ); | ||
|
||
BOOST_CHECK_NO_THROW( t_suite2->add( BOOST_TEST_CASE( suite1_test1 ) ) ); | ||
} | ||
|
||
BOOST_TEST_CASE_TEMPLATE_FUNCTION( template_test_case, T ) | ||
{ | ||
BOOST_TEST( sizeof(T) == 4U ); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE( test_clashing_cases_template_test_case ) | ||
{ | ||
using namespace boost::unit_test; | ||
test_suite* master_ts = BOOST_TEST_SUITE("local master"); | ||
test_suite* t_suite1 = BOOST_TEST_SUITE( "suite1" ); | ||
test_suite* t_suite2 = BOOST_TEST_SUITE( "suite2" ); | ||
master_ts->add(t_suite1); | ||
master_ts->add(t_suite2); | ||
|
||
typedef boost::mpl::list<int, long, unsigned char> test_types1; | ||
typedef boost::mpl::list<int, long, unsigned char, int> test_types2; | ||
|
||
BOOST_CHECK_NO_THROW( t_suite2->add( BOOST_TEST_CASE_TEMPLATE( template_test_case, test_types1 ) ) ); | ||
BOOST_CHECK_THROW( t_suite1->add( BOOST_TEST_CASE_TEMPLATE( template_test_case, test_types2 ) ), | ||
boost::unit_test::framework::setup_error ); | ||
} |
I understand the general rationale for adding such a test. However, it breaks fairly innocent tests over type lists. E.g. I have tests for bit-twiddling code over
unsigned
,unsigned long
andunsigned long long
, as well asuint32_t
anduint64_t
. On most architectures this has 2 independent types, but I would like not to have to specify which types are redundant. With Boost 1.67 this now breaks my existing code. It it possible to guard this with a macro that can be opted-out as a build option? E.g.BOOST_TEST_DUPLICATE_CHECK
or something like that?