|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49865 - in trunk/boost/test: . detail impl
From: gennadiy.rozental_at_[hidden]
Date: 2008-11-21 17:38:33
Author: rogeeff
Date: 2008-11-21 17:38:32 EST (Fri, 21 Nov 2008)
New Revision: 49865
URL: http://svn.boost.org/trac/boost/changeset/49865
Log:
fix gcc warnings and resolve ODR violation issue #2390
Text files modified:
trunk/boost/test/detail/global_typedef.hpp | 16 ++++++++++++++++
trunk/boost/test/floating_point_comparison.hpp | 12 +++++++-----
trunk/boost/test/impl/framework.ipp | 2 +-
trunk/boost/test/impl/unit_test_suite.ipp | 4 ++--
trunk/boost/test/parameterized_test.hpp | 2 +-
5 files changed, 27 insertions(+), 9 deletions(-)
Modified: trunk/boost/test/detail/global_typedef.hpp
==============================================================================
--- trunk/boost/test/detail/global_typedef.hpp (original)
+++ trunk/boost/test/detail/global_typedef.hpp 2008-11-21 17:38:32 EST (Fri, 21 Nov 2008)
@@ -45,6 +45,7 @@
//____________________________________________________________________________//
typedef unsigned long test_unit_id;
+
const test_unit_id INV_TEST_UNIT_ID = 0xFFFFFFFF;
const test_unit_id MAX_TEST_CASE_ID = 0xFFFFFFFE;
const test_unit_id MIN_TEST_CASE_ID = 0x00010000;
@@ -53,6 +54,8 @@
//____________________________________________________________________________//
+namespace ut_detail {
+
inline test_unit_type
test_id_2_unit_type( test_unit_id id )
{
@@ -61,6 +64,19 @@
//____________________________________________________________________________//
+// helper templates to prevent ODR violations
+template<class T>
+struct static_constant {
+ static T value;
+};
+
+template<class T>
+T static_constant<T>::value;
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
} // namespace unit_test
} // namespace boost
Modified: trunk/boost/test/floating_point_comparison.hpp
==============================================================================
--- trunk/boost/test/floating_point_comparison.hpp (original)
+++ trunk/boost/test/floating_point_comparison.hpp 2008-11-21 17:38:32 EST (Fri, 21 Nov 2008)
@@ -17,6 +17,8 @@
#include <boost/limits.hpp> // for std::numeric_limits
+// Boost.Test
+#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/utils/class_properties.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -79,12 +81,12 @@
safe_fpt_division( FPT f1, FPT f2 )
{
// Avoid overflow.
- if( f2 < static_cast<FPT>(1) && f1 > f2*fpt_limits<FPT>::max_value() )
+ if( (f2 < static_cast<FPT>(1)) && (f1 > f2*fpt_limits<FPT>::max_value()) )
return fpt_limits<FPT>::max_value();
// Avoid underflow.
- if( f1 == static_cast<FPT>(0) ||
- f2 > static_cast<FPT>(1) && f1 < f2*fpt_limits<FPT>::min_value() )
+ if( (f1 == static_cast<FPT>(0)) ||
+ (f2 > static_cast<FPT>(1)) && (f1 < f2*fpt_limits<FPT>::min_value()) )
return static_cast<FPT>(0);
return f1/f2;
@@ -221,7 +223,7 @@
};
namespace {
-check_is_close_t check_is_close;
+check_is_close_t const& check_is_close = unit_test::ut_detail::static_constant<check_is_close_t>::value;
}
//____________________________________________________________________________//
@@ -243,7 +245,7 @@
};
namespace {
-check_is_small_t check_is_small;
+check_is_small_t const& check_is_small = unit_test::ut_detail::static_constant<check_is_small_t>::value;
}
//____________________________________________________________________________//
Modified: trunk/boost/test/impl/framework.ipp
==============================================================================
--- trunk/boost/test/impl/framework.ipp (original)
+++ trunk/boost/test/impl/framework.ipp 2008-11-21 17:38:32 EST (Fri, 21 Nov 2008)
@@ -127,7 +127,7 @@
test_unit_store::value_type const& tu = *m_test_units.begin();
// the delete will erase this element from map
- if( test_id_2_unit_type( tu.second->p_id ) == tut_suite )
+ if( ut_detail::test_id_2_unit_type( tu.second->p_id ) == tut_suite )
delete (test_suite const*)tu.second;
else
delete (test_case const*)tu.second;
Modified: trunk/boost/test/impl/unit_test_suite.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_suite.ipp (original)
+++ trunk/boost/test/impl/unit_test_suite.ipp 2008-11-21 17:38:32 EST (Fri, 21 Nov 2008)
@@ -173,7 +173,7 @@
test_suite::get( const_string tu_name ) const
{
BOOST_TEST_FOREACH( test_unit_id, id, m_members ) {
- if( tu_name == framework::get( id, test_id_2_unit_type( id ) ).p_name.get() )
+ if( tu_name == framework::get( id, ut_detail::test_id_2_unit_type( id ) ).p_name.get() )
return id;
}
@@ -228,7 +228,7 @@
void
traverse_test_tree( test_unit_id id, test_tree_visitor& V )
{
- if( test_id_2_unit_type( id ) == tut_case )
+ if( ut_detail::test_id_2_unit_type( id ) == tut_case )
traverse_test_tree( framework::get<test_case>( id ), V );
else
traverse_test_tree( framework::get<test_suite>( id ), V );
Modified: trunk/boost/test/parameterized_test.hpp
==============================================================================
--- trunk/boost/test/parameterized_test.hpp (original)
+++ trunk/boost/test/parameterized_test.hpp 2008-11-21 17:38:32 EST (Fri, 21 Nov 2008)
@@ -82,7 +82,7 @@
, m_par_end( par_end )
{}
- test_unit* next() const
+ virtual test_unit* next() const
{
if( m_par_begin == m_par_end )
return (test_unit*)0;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk