Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81234 - trunk/libs/smart_ptr/test
From: pdimov_at_[hidden]
Date: 2012-11-07 10:33:44


Author: pdimov
Date: 2012-11-07 10:33:44 EST (Wed, 07 Nov 2012)
New Revision: 81234
URL: http://svn.boost.org/trac/boost/changeset/81234

Log:
Add sp_convertible_test.cpp.
Added:
   trunk/libs/smart_ptr/test/sp_convertible_test.cpp (contents, props changed)
Text files modified:
   trunk/libs/smart_ptr/test/Jamfile.v2 | 1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

Modified: trunk/libs/smart_ptr/test/Jamfile.v2
==============================================================================
--- trunk/libs/smart_ptr/test/Jamfile.v2 (original)
+++ trunk/libs/smart_ptr/test/Jamfile.v2 2012-11-07 10:33:44 EST (Wed, 07 Nov 2012)
@@ -72,6 +72,7 @@
           [ run sp_unique_ptr_test.cpp ]
           [ run sp_array_test.cpp ]
           [ compile sp_array_cv_test.cpp ]
+ [ run sp_convertible_test.cpp ]
 
           [ compile-fail array_fail_spa_sp_c.cpp ]
           [ compile-fail array_fail_sp_spa_c.cpp ]

Added: trunk/libs/smart_ptr/test/sp_convertible_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/sp_convertible_test.cpp 2012-11-07 10:33:44 EST (Wed, 07 Nov 2012)
@@ -0,0 +1,93 @@
+#include <boost/config.hpp>
+
+// sp_convertible_test.cpp
+//
+// Copyright (c) 2012 Peter Dimov
+//
+// 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
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/smart_ptr/detail/sp_convertible.hpp>
+
+//
+
+class X;
+
+class B
+{
+};
+
+class D: public B
+{
+};
+
+#define TEST_CV_TRUE( T, U ) \
+ BOOST_TEST(( sp_convertible< T, U >::value == true )); \
+ BOOST_TEST(( sp_convertible< T, const U >::value == true )); \
+ BOOST_TEST(( sp_convertible< T, volatile U >::value == true )); \
+ BOOST_TEST(( sp_convertible< T, const volatile U >::value == true )); \
+ BOOST_TEST(( sp_convertible< const T, U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const T, const U >::value == true )); \
+ BOOST_TEST(( sp_convertible< const T, volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const T, const volatile U >::value == true )); \
+ BOOST_TEST(( sp_convertible< volatile T, U >::value == false )); \
+ BOOST_TEST(( sp_convertible< volatile T, const U >::value == false )); \
+ BOOST_TEST(( sp_convertible< volatile T, volatile U >::value == true )); \
+ BOOST_TEST(( sp_convertible< volatile T, const volatile U >::value == true )); \
+ BOOST_TEST(( sp_convertible< const volatile T, U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const volatile T, const U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const volatile T, volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const volatile T, const volatile U >::value == true ));
+
+#define TEST_CV_FALSE( T, U ) \
+ BOOST_TEST(( sp_convertible< T, U >::value == false )); \
+ BOOST_TEST(( sp_convertible< T, const U >::value == false )); \
+ BOOST_TEST(( sp_convertible< T, volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< T, const volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const T, U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const T, const U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const T, volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const T, const volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< volatile T, U >::value == false )); \
+ BOOST_TEST(( sp_convertible< volatile T, const U >::value == false )); \
+ BOOST_TEST(( sp_convertible< volatile T, volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< volatile T, const volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const volatile T, U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const volatile T, const U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const volatile T, volatile U >::value == false )); \
+ BOOST_TEST(( sp_convertible< const volatile T, const volatile U >::value == false ));
+
+int main()
+{
+#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
+
+ using boost::detail::sp_convertible;
+
+ TEST_CV_TRUE( X, X )
+ TEST_CV_TRUE( X, void )
+ TEST_CV_FALSE( void, X )
+ TEST_CV_TRUE( D, B )
+ TEST_CV_FALSE( B, D )
+
+ TEST_CV_TRUE( X[], X[] )
+ TEST_CV_FALSE( D[], B[] )
+
+ TEST_CV_TRUE( X[3], X[3] )
+ TEST_CV_FALSE( X[3], X[4] )
+ TEST_CV_FALSE( D[3], B[3] )
+
+ //TEST_CV_TRUE( X[3], X[] )
+ TEST_CV_FALSE( X[], X[3] )
+
+ TEST_CV_TRUE( X[], void )
+ TEST_CV_FALSE( void, X[] )
+
+ TEST_CV_TRUE( X[3], void )
+ TEST_CV_FALSE( void, X[3] )
+
+#endif
+
+ return boost::report_errors();
+}


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