Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65519 - sandbox/chrono/libs/type_traits_ext/test
From: vicente.botet_at_[hidden]
Date: 2010-09-21 14:50:54


Author: viboes
Date: 2010-09-21 14:50:52 EDT (Tue, 21 Sep 2010)
New Revision: 65519
URL: http://svn.boost.org/trac/boost/changeset/65519

Log:
TypeTraits.Ext add basic tests on common_type
Text files modified:
   sandbox/chrono/libs/type_traits_ext/test/Jamfile.v2 | 1 +
   sandbox/chrono/libs/type_traits_ext/test/common_type_fails.cpp | 2 +-
   sandbox/chrono/libs/type_traits_ext/test/common_type_test.cpp | 19 +++++++++++++++++++
   3 files changed, 21 insertions(+), 1 deletions(-)

Modified: sandbox/chrono/libs/type_traits_ext/test/Jamfile.v2
==============================================================================
--- sandbox/chrono/libs/type_traits_ext/test/Jamfile.v2 (original)
+++ sandbox/chrono/libs/type_traits_ext/test/Jamfile.v2 2010-09-21 14:50:52 EDT (Tue, 21 Sep 2010)
@@ -25,6 +25,7 @@
         #<include>../../..
         <toolset>msvc:<asynch-exceptions>on
         <define>BOOST_ENABLE_WARNINGS
+ <define>BOOST_COMMON_TYPE_DONT_USE_TYPEOF
         <warnings>all
         <toolset>gcc:<cxxflags>-Wextra
         <toolset>gcc:<cxxflags>-Wno-long-long

Modified: sandbox/chrono/libs/type_traits_ext/test/common_type_fails.cpp
==============================================================================
--- sandbox/chrono/libs/type_traits_ext/test/common_type_fails.cpp (original)
+++ sandbox/chrono/libs/type_traits_ext/test/common_type_fails.cpp 2010-09-21 14:50:52 EDT (Tue, 21 Sep 2010)
@@ -33,5 +33,5 @@
 typedef std::common_type<C1, C2>::type AC;
 #endif
 //~ AC* ac;
-
+
     
\ No newline at end of file

Modified: sandbox/chrono/libs/type_traits_ext/test/common_type_test.cpp
==============================================================================
--- sandbox/chrono/libs/type_traits_ext/test/common_type_test.cpp (original)
+++ sandbox/chrono/libs/type_traits_ext/test/common_type_test.cpp 2010-09-21 14:50:52 EDT (Tue, 21 Sep 2010)
@@ -9,6 +9,8 @@
 
 #include <boost/type_traits/common_type.hpp>
 #include <iostream>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
 
 #include <boost/test/minimal.hpp>
 
@@ -86,7 +88,24 @@
     typedef boost::common_type<int volatile*, int const*>::type T4; // fails if BOOST_COMMON_TYPE_DONT_USE_TYPEOF
     typedef boost::common_type<int*, int volatile*>::type T5;
     //~ typedef boost::common_type<short volatile*, int const*>::type T5; // fails
+ //~ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<unsigned char, unsigned short>::type, unsigned int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<char, short>::type, int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<short, char>::type, int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<unsigned char, short>::type, int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<short, unsigned char>::type, int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<char, unsigned short>::type, int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<unsigned short, char>::type, int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<unsigned char, unsigned short>::type, int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<unsigned short, unsigned char>::type, int>::value));
 
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<int>::type, int>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<char>::type, char>::value));
+
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<double, char>::type, double>::value));
+
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<double, char, long long>::type, double>::value));
+ BOOST_STATIC_ASSERT((boost::is_same<boost::common_type<unsigned, char, long long>::type, long long>::value));
+
     assignation_2<C1, C1C2>();
     assignation_2<C1C2, C2>();
     assignation_2<C2, C1C2>();


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