From ca7a01a593a357c8e1ab8e5eb5073c820f392616 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 21 Jun 2017 04:07:17 +0300 Subject: [PATCH] Add more tests. Update Jamfile to new style. --- test/Jamfile | 247 +++++++++++++++++++++++++++++++++ test/Jamfile.v2 | 247 --------------------------------- test/lsp_convertible_test.cpp | 108 ++++++++++++++ test/lsp_convertible_test2.cpp | 108 ++++++++++++++ test/sp_convertible_test2.cpp | 108 ++++++++++++++ 5 files changed, 571 insertions(+), 247 deletions(-) create mode 100644 test/Jamfile delete mode 100644 test/Jamfile.v2 create mode 100644 test/lsp_convertible_test.cpp create mode 100644 test/lsp_convertible_test2.cpp create mode 100644 test/sp_convertible_test2.cpp diff --git a/test/Jamfile b/test/Jamfile new file mode 100644 index 0000000..a80e655 --- /dev/null +++ b/test/Jamfile @@ -0,0 +1,247 @@ +# Boost.SmartPtr Library test Jamfile +# +# Copyright (c) 2003-2017 Peter Dimov +# Copyright (c) 2003 Dave Abrahams +# +# 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) + +# bring in rules for testing +import testing ; + +run smart_ptr_test.cpp ; +run shared_ptr_basic_test.cpp : : : gcc:-Wno-non-virtual-dtor ; +run shared_ptr_test.cpp : : : gcc:-Wno-non-virtual-dtor ; +run weak_ptr_test.cpp ; +run weak_ptr_move_test.cpp ; +run shared_from_this_test.cpp : : : gcc:-Wno-non-virtual-dtor ; +run get_deleter_test.cpp ; +run intrusive_ptr_test.cpp ; +run intrusive_ptr_move_test.cpp ; +run intrusive_ref_counter_test.cpp ; +run atomic_count_test.cpp ; +run lw_mutex_test.cpp ; +compile-fail shared_ptr_assign_fail.cpp ; +compile-fail shared_ptr_delete_fail.cpp ; +compile-fail shared_ptr_compare_fail.cpp ; +run shared_ptr_alloc2_test.cpp ; +run pointer_cast_test.cpp ; +run cpp11_pointer_cast_test.cpp ; +compile pointer_to_other_test.cpp ; +run auto_ptr_rv_test.cpp ; +run shared_ptr_alias_test.cpp ; +run shared_ptr_rv_test.cpp ; +run shared_ptr_rv_pointer_cast_test.cpp ; +run shared_ptr_move_test.cpp ; +run shared_ptr_alias_move_test.cpp ; +run shared_ptr_reinterpret_pointer_cast_test.cpp ; +compile-fail shared_ptr_pv_fail.cpp ; +run sp_unary_addr_test.cpp ; +compile-fail scoped_ptr_eq_fail.cpp ; +compile-fail scoped_array_eq_fail.cpp ; +run esft_regtest.cpp ; +run yield_k_test.cpp ; +run yield_k_test.cpp : : : multi : yield_k_test.mt ; +run spinlock_test.cpp ; +run spinlock_try_test.cpp ; +run spinlock_try_test.cpp : : : multi : spinlock_try_test.mt ; +run spinlock_pool_test.cpp ; +run make_shared_test.cpp ; +run make_shared_move_emulation_test.cpp ; +run make_shared_perfect_forwarding_test.cpp ; +run shared_ptr_convertible_test.cpp ; +run wp_convertible_test.cpp ; +run ip_convertible_test.cpp ; +run allocate_shared_test.cpp ; +run sp_atomic_test.cpp ; +run esft_void_test.cpp ; +run esft_second_ptr_test.cpp ; +run make_shared_esft_test.cpp ; +run allocate_shared_esft_test.cpp ; +run sp_recursive_assign_test.cpp ; +run sp_recursive_assign2_test.cpp ; +run sp_recursive_assign_rv_test.cpp ; +run sp_recursive_assign2_rv_test.cpp ; +compile-fail auto_ptr_lv_fail.cpp ; +run atomic_count_test2.cpp ; +run sp_typeinfo_test.cpp ; +compile make_shared_fp_test.cpp ; +run sp_hash_test.cpp ; +run get_deleter_array_test.cpp ; +run ip_hash_test.cpp ; +run owner_less_test.cpp ; +run sp_unique_ptr_test.cpp ; +run sp_array_test.cpp ; +compile sp_array_cv_test.cpp ; +run sp_convertible_test.cpp ; +run sp_array_n_test.cpp ; +run sp_array_cast_test.cpp ; +run sp_zero_compare_test.cpp ; +run sp_nullptr_test.cpp ; +run sa_nullptr_test.cpp ; +run shared_ptr_alloc3_test.cpp ; +run shared_ptr_alloc11_test.cpp ; +run shared_ptr_alloc_construct11_test.cpp ; +run allocate_shared_alloc11_test.cpp ; +run allocate_shared_construct11_test.cpp ; +run sp_interlocked_test.cpp ; + +compile-fail array_fail_spa_sp_c.cpp ; +compile-fail array_fail_sp_spa_c.cpp ; +compile-fail array_fail_spa_spa_c.cpp ; +compile-fail array_fail_spa_wp_c.cpp ; +compile-fail array_fail_sp_wpa_c.cpp ; +compile-fail array_fail_spa_wpa_c.cpp ; +compile-fail array_fail_wpa_wp_c.cpp ; +compile-fail array_fail_wp_wpa_c.cpp ; +compile-fail array_fail_wpa_wpa_c.cpp ; +compile-fail array_fail_ap_spa_c.cpp ; +compile-fail array_fail_upa_sp_c.cpp ; +compile-fail array_fail_up_spa_c.cpp ; + +compile-fail array_fail_spa_sp_mc.cpp ; +compile-fail array_fail_sp_spa_mc.cpp ; +compile-fail array_fail_spa_spa_mc.cpp ; +compile-fail array_fail_spa_wp_mc.cpp ; +compile-fail array_fail_sp_wpa_mc.cpp ; +compile-fail array_fail_spa_wpa_mc.cpp ; +compile-fail array_fail_wpa_wp_mc.cpp ; +compile-fail array_fail_wp_wpa_mc.cpp ; +compile-fail array_fail_wpa_wpa_mc.cpp ; +compile-fail array_fail_ap_spa_mc.cpp ; +compile-fail array_fail_upa_sp_mc.cpp ; +compile-fail array_fail_up_spa_mc.cpp ; + +compile-fail array_fail_spa_sp_a.cpp ; +compile-fail array_fail_sp_spa_a.cpp ; +compile-fail array_fail_spa_spa_a.cpp ; +compile-fail array_fail_spa_wp_a.cpp ; +compile-fail array_fail_sp_wpa_a.cpp ; +compile-fail array_fail_spa_wpa_a.cpp ; +compile-fail array_fail_wpa_wp_a.cpp ; +compile-fail array_fail_wp_wpa_a.cpp ; +compile-fail array_fail_wpa_wpa_a.cpp ; +compile-fail array_fail_ap_spa_a.cpp ; +compile-fail array_fail_upa_sp_a.cpp ; +compile-fail array_fail_up_spa_a.cpp ; + +compile-fail array_fail_spa_sp_ma.cpp ; +compile-fail array_fail_sp_spa_ma.cpp ; +compile-fail array_fail_spa_spa_ma.cpp ; +compile-fail array_fail_spa_wp_ma.cpp ; +compile-fail array_fail_sp_wpa_ma.cpp ; +compile-fail array_fail_spa_wpa_ma.cpp ; +compile-fail array_fail_wpa_wp_ma.cpp ; +compile-fail array_fail_wp_wpa_ma.cpp ; +compile-fail array_fail_wpa_wpa_ma.cpp ; +compile-fail array_fail_ap_spa_ma.cpp ; +compile-fail array_fail_upa_sp_ma.cpp ; +compile-fail array_fail_up_spa_ma.cpp ; + +compile-fail array_fail_dereference.cpp ; +compile-fail array_fail_member_access.cpp ; +compile-fail array_fail_array_access.cpp ; + +run make_shared_array_test.cpp ; +run make_shared_arrays_test.cpp : : : gcc-4.6.3_0x:-fno-deduce-init-list ; +run make_shared_array_throws_test.cpp ; +run make_shared_array_esft_test.cpp ; +run make_shared_array_noinit_test.cpp ; +run make_shared_array_value_test.cpp ; +run allocate_shared_array_test.cpp ; +run allocate_shared_arrays_test.cpp : : : gcc-4.6.3_0x:-fno-deduce-init-list ; +run allocate_shared_array_throws_test.cpp ; +run allocate_shared_array_esft_test.cpp ; +run allocate_shared_array_noinit_test.cpp ; +run allocate_shared_array_value_test.cpp ; +run allocate_shared_array_construct_test.cpp ; + +run make_unique_test.cpp ; +run make_unique_args_test.cpp ; +run make_unique_value_test.cpp ; +run make_unique_noinit_test.cpp ; +run make_unique_throws_test.cpp ; +run make_unique_array_test.cpp ; +run make_unique_array_noinit_test.cpp ; +run make_unique_array_throws_test.cpp ; + +run shared_from_raw_test.cpp ; +run shared_from_raw_test2.cpp ; +run shared_from_raw_test3.cpp ; +run shared_from_raw_test4.cpp ; +run shared_from_raw_test5.cpp ; +run shared_from_raw_test6.cpp ; + +run weak_from_raw_test.cpp ; +run weak_from_raw_test2.cpp ; +run weak_from_raw_test3.cpp ; +run weak_from_raw_test4.cpp ; +run weak_from_raw_test5.cpp ; + +compile sp_explicit_inst_test.cpp ; + +run weak_from_this_test.cpp ; +run weak_from_this_test2.cpp ; + +run sp_bml_unique_ptr_test.cpp ; + +run sp_hash_test2.cpp ; +run sp_hash_test3.cpp ; + +run pointer_cast_test2.cpp ; + +compile-fail pointer_cast_st_fail.cpp ; +compile-fail pointer_cast_st_fail2.cpp ; +compile-fail pointer_cast_st_fail3.cpp ; + +compile-fail pointer_cast_co_fail.cpp ; +compile-fail pointer_cast_co_fail2.cpp ; +compile-fail pointer_cast_co_fail3.cpp ; + +compile-fail pointer_cast_dy_fail.cpp ; +compile-fail pointer_cast_dy_fail2.cpp ; +compile-fail pointer_cast_dy_fail3.cpp ; + +run sp_nothrow_test.cpp ; + +compile make_shared_msvc_test.cpp ; + +compile lwm_win32_cs_test.cpp ; + +run atomic_sp_test.cpp ; + +run sp_constexpr_test.cpp ; +run sp_constexpr_test2.cpp ; + +run atomic_sp_constexpr_test.cpp ; + +run shared_ptr_fn_test.cpp ; + +run get_deleter_test2.cpp ; +run get_deleter_test3.cpp ; +run get_deleter_array_test2.cpp ; +run get_deleter_array_test3.cpp ; + +run sp_convertible_test2.cpp ; + +run local_sp_test.cpp ; +run lsp_array_test.cpp ; +run lsp_array_n_test.cpp ; +run lsp_array_cv_test.cpp ; +run lsp_array_cast_test.cpp ; + +run get_local_deleter_test.cpp ; +run get_local_deleter_test2.cpp ; +run get_local_deleter_test3.cpp ; +run get_local_deleter_array_test.cpp ; +run get_local_deleter_array_test2.cpp ; + +run make_local_shared_test.cpp ; +run make_local_shared_esft_test.cpp ; +run allocate_local_shared_test.cpp ; +run allocate_local_shared_esft_test.cpp ; + +run local_sp_fn_test.cpp ; +run lsp_convertible_test.cpp ; +run lsp_convertible_test2.cpp ; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index 134642d..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,247 +0,0 @@ -# Boost.SmartPtr Library test Jamfile -# -# Copyright (c) 2003-2017 Peter Dimov -# Copyright (c) 2003 Dave Abrahams -# -# 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) - -# bring in rules for testing -import testing ; - -{ - test-suite "smart_ptr" - : [ run smart_ptr_test.cpp ] - [ run shared_ptr_basic_test.cpp : : : gcc:-Wno-non-virtual-dtor ] - [ run shared_ptr_test.cpp : : : gcc:-Wno-non-virtual-dtor ] - [ run weak_ptr_test.cpp ] - [ run weak_ptr_move_test.cpp ] - [ run shared_from_this_test.cpp : : : gcc:-Wno-non-virtual-dtor ] - [ run get_deleter_test.cpp ] - [ run intrusive_ptr_test.cpp ] - [ run intrusive_ptr_move_test.cpp ] - [ run intrusive_ref_counter_test.cpp ] - [ run atomic_count_test.cpp ] - [ run lw_mutex_test.cpp ] - [ compile-fail shared_ptr_assign_fail.cpp ] - [ compile-fail shared_ptr_delete_fail.cpp ] - [ compile-fail shared_ptr_compare_fail.cpp ] - [ run shared_ptr_alloc2_test.cpp ] - [ run pointer_cast_test.cpp ] - [ run cpp11_pointer_cast_test.cpp ] - [ compile pointer_to_other_test.cpp ] - [ run auto_ptr_rv_test.cpp ] - [ run shared_ptr_alias_test.cpp ] - [ run shared_ptr_rv_test.cpp ] - [ run shared_ptr_rv_pointer_cast_test.cpp ] - [ run shared_ptr_move_test.cpp ] - [ run shared_ptr_alias_move_test.cpp ] - [ run shared_ptr_reinterpret_pointer_cast_test.cpp ] - [ compile-fail shared_ptr_pv_fail.cpp ] - [ run sp_unary_addr_test.cpp ] - [ compile-fail scoped_ptr_eq_fail.cpp ] - [ compile-fail scoped_array_eq_fail.cpp ] - [ run esft_regtest.cpp ] - [ run yield_k_test.cpp ] - [ run yield_k_test.cpp : : : multi : yield_k_test.mt ] - [ run spinlock_test.cpp ] - [ run spinlock_try_test.cpp ] - [ run spinlock_try_test.cpp : : : multi : spinlock_try_test.mt ] - [ run spinlock_pool_test.cpp ] - [ run make_shared_test.cpp ] - [ run make_shared_move_emulation_test.cpp ] - [ run make_shared_perfect_forwarding_test.cpp ] - [ run shared_ptr_convertible_test.cpp ] - [ run wp_convertible_test.cpp ] - [ run ip_convertible_test.cpp ] - [ run allocate_shared_test.cpp ] - [ run sp_atomic_test.cpp ] - [ run esft_void_test.cpp ] - [ run esft_second_ptr_test.cpp ] - [ run make_shared_esft_test.cpp ] - [ run allocate_shared_esft_test.cpp ] - [ run sp_recursive_assign_test.cpp ] - [ run sp_recursive_assign2_test.cpp ] - [ run sp_recursive_assign_rv_test.cpp ] - [ run sp_recursive_assign2_rv_test.cpp ] - [ compile-fail auto_ptr_lv_fail.cpp ] - [ run atomic_count_test2.cpp ] - [ run sp_typeinfo_test.cpp ] - [ compile make_shared_fp_test.cpp ] - [ run sp_hash_test.cpp ] - [ run get_deleter_array_test.cpp ] - [ run ip_hash_test.cpp ] - [ run owner_less_test.cpp ] - [ run sp_unique_ptr_test.cpp ] - [ run sp_array_test.cpp ] - [ compile sp_array_cv_test.cpp ] - [ run sp_convertible_test.cpp ] - [ run sp_array_n_test.cpp ] - [ run sp_array_cast_test.cpp ] - [ run sp_zero_compare_test.cpp ] - [ run sp_nullptr_test.cpp ] - [ run sa_nullptr_test.cpp ] - [ run shared_ptr_alloc3_test.cpp ] - [ run shared_ptr_alloc11_test.cpp ] - [ run shared_ptr_alloc_construct11_test.cpp ] - [ run allocate_shared_alloc11_test.cpp ] - [ run allocate_shared_construct11_test.cpp ] - [ run sp_interlocked_test.cpp ] - - [ compile-fail array_fail_spa_sp_c.cpp ] - [ compile-fail array_fail_sp_spa_c.cpp ] - [ compile-fail array_fail_spa_spa_c.cpp ] - [ compile-fail array_fail_spa_wp_c.cpp ] - [ compile-fail array_fail_sp_wpa_c.cpp ] - [ compile-fail array_fail_spa_wpa_c.cpp ] - [ compile-fail array_fail_wpa_wp_c.cpp ] - [ compile-fail array_fail_wp_wpa_c.cpp ] - [ compile-fail array_fail_wpa_wpa_c.cpp ] - [ compile-fail array_fail_ap_spa_c.cpp ] - [ compile-fail array_fail_upa_sp_c.cpp ] - [ compile-fail array_fail_up_spa_c.cpp ] - - [ compile-fail array_fail_spa_sp_mc.cpp ] - [ compile-fail array_fail_sp_spa_mc.cpp ] - [ compile-fail array_fail_spa_spa_mc.cpp ] - [ compile-fail array_fail_spa_wp_mc.cpp ] - [ compile-fail array_fail_sp_wpa_mc.cpp ] - [ compile-fail array_fail_spa_wpa_mc.cpp ] - [ compile-fail array_fail_wpa_wp_mc.cpp ] - [ compile-fail array_fail_wp_wpa_mc.cpp ] - [ compile-fail array_fail_wpa_wpa_mc.cpp ] - [ compile-fail array_fail_ap_spa_mc.cpp ] - [ compile-fail array_fail_upa_sp_mc.cpp ] - [ compile-fail array_fail_up_spa_mc.cpp ] - - [ compile-fail array_fail_spa_sp_a.cpp ] - [ compile-fail array_fail_sp_spa_a.cpp ] - [ compile-fail array_fail_spa_spa_a.cpp ] - [ compile-fail array_fail_spa_wp_a.cpp ] - [ compile-fail array_fail_sp_wpa_a.cpp ] - [ compile-fail array_fail_spa_wpa_a.cpp ] - [ compile-fail array_fail_wpa_wp_a.cpp ] - [ compile-fail array_fail_wp_wpa_a.cpp ] - [ compile-fail array_fail_wpa_wpa_a.cpp ] - [ compile-fail array_fail_ap_spa_a.cpp ] - [ compile-fail array_fail_upa_sp_a.cpp ] - [ compile-fail array_fail_up_spa_a.cpp ] - - [ compile-fail array_fail_spa_sp_ma.cpp ] - [ compile-fail array_fail_sp_spa_ma.cpp ] - [ compile-fail array_fail_spa_spa_ma.cpp ] - [ compile-fail array_fail_spa_wp_ma.cpp ] - [ compile-fail array_fail_sp_wpa_ma.cpp ] - [ compile-fail array_fail_spa_wpa_ma.cpp ] - [ compile-fail array_fail_wpa_wp_ma.cpp ] - [ compile-fail array_fail_wp_wpa_ma.cpp ] - [ compile-fail array_fail_wpa_wpa_ma.cpp ] - [ compile-fail array_fail_ap_spa_ma.cpp ] - [ compile-fail array_fail_upa_sp_ma.cpp ] - [ compile-fail array_fail_up_spa_ma.cpp ] - - [ compile-fail array_fail_dereference.cpp ] - [ compile-fail array_fail_member_access.cpp ] - [ compile-fail array_fail_array_access.cpp ] - - [ run make_shared_array_test.cpp ] - [ run make_shared_arrays_test.cpp : : : gcc-4.6.3_0x:-fno-deduce-init-list ] - [ run make_shared_array_throws_test.cpp ] - [ run make_shared_array_esft_test.cpp ] - [ run make_shared_array_noinit_test.cpp ] - [ run make_shared_array_value_test.cpp ] - [ run allocate_shared_array_test.cpp ] - [ run allocate_shared_arrays_test.cpp : : : gcc-4.6.3_0x:-fno-deduce-init-list ] - [ run allocate_shared_array_throws_test.cpp ] - [ run allocate_shared_array_esft_test.cpp ] - [ run allocate_shared_array_noinit_test.cpp ] - [ run allocate_shared_array_value_test.cpp ] - [ run allocate_shared_array_construct_test.cpp ] - - [ run make_unique_test.cpp ] - [ run make_unique_args_test.cpp ] - [ run make_unique_value_test.cpp ] - [ run make_unique_noinit_test.cpp ] - [ run make_unique_throws_test.cpp ] - [ run make_unique_array_test.cpp ] - [ run make_unique_array_noinit_test.cpp ] - [ run make_unique_array_throws_test.cpp ] - - [ run shared_from_raw_test.cpp ] - [ run shared_from_raw_test2.cpp ] - [ run shared_from_raw_test3.cpp ] - [ run shared_from_raw_test4.cpp ] - [ run shared_from_raw_test5.cpp ] - [ run shared_from_raw_test6.cpp ] - - [ run weak_from_raw_test.cpp ] - [ run weak_from_raw_test2.cpp ] - [ run weak_from_raw_test3.cpp ] - [ run weak_from_raw_test4.cpp ] - [ run weak_from_raw_test5.cpp ] - - [ compile sp_explicit_inst_test.cpp ] - - [ run weak_from_this_test.cpp ] - [ run weak_from_this_test2.cpp ] - - [ run sp_bml_unique_ptr_test.cpp ] - - [ run sp_hash_test2.cpp ] - [ run sp_hash_test3.cpp ] - - [ run pointer_cast_test2.cpp ] - - [ compile-fail pointer_cast_st_fail.cpp ] - [ compile-fail pointer_cast_st_fail2.cpp ] - [ compile-fail pointer_cast_st_fail3.cpp ] - - [ compile-fail pointer_cast_co_fail.cpp ] - [ compile-fail pointer_cast_co_fail2.cpp ] - [ compile-fail pointer_cast_co_fail3.cpp ] - - [ compile-fail pointer_cast_dy_fail.cpp ] - [ compile-fail pointer_cast_dy_fail2.cpp ] - [ compile-fail pointer_cast_dy_fail3.cpp ] - - [ run sp_nothrow_test.cpp ] - - [ compile make_shared_msvc_test.cpp ] - - [ compile lwm_win32_cs_test.cpp ] - - [ run atomic_sp_test.cpp ] - - [ run sp_constexpr_test.cpp ] - [ run sp_constexpr_test2.cpp ] - - [ run atomic_sp_constexpr_test.cpp ] - - [ run shared_ptr_fn_test.cpp ] - - [ run get_deleter_test2.cpp ] - [ run get_deleter_test3.cpp ] - [ run get_deleter_array_test2.cpp ] - [ run get_deleter_array_test3.cpp ] - - [ run local_sp_test.cpp ] - [ run lsp_array_test.cpp ] - [ run lsp_array_n_test.cpp ] - [ run lsp_array_cv_test.cpp ] - [ run lsp_array_cast_test.cpp ] - - [ run get_local_deleter_test.cpp ] - [ run get_local_deleter_test2.cpp ] - [ run get_local_deleter_test3.cpp ] - [ run get_local_deleter_array_test.cpp ] - [ run get_local_deleter_array_test2.cpp ] - - [ run make_local_shared_test.cpp ] - [ run make_local_shared_esft_test.cpp ] - [ run allocate_local_shared_test.cpp ] - [ run allocate_local_shared_esft_test.cpp ] - - [ run local_sp_fn_test.cpp ] - ; -} diff --git a/test/lsp_convertible_test.cpp b/test/lsp_convertible_test.cpp new file mode 100644 index 0000000..4f5017a --- /dev/null +++ b/test/lsp_convertible_test.cpp @@ -0,0 +1,108 @@ +#include + +// lsp_convertible_test.cpp +// +// Copyright 2012, 2017 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 +#include +#include +#include +#include + +// + +class X; + +class B +{ +}; + +class D: public B +{ +}; + +using boost::is_convertible; + +#define TEST_CV_TRUE_( S1, T, S2, U ) \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); + +#define TEST_CV_FALSE_( S1, T, S2, U ) \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); + +using boost::local_shared_ptr; +using boost::shared_ptr; +using boost::weak_ptr; + +#define TEST_CV_TRUE( T, U ) \ + TEST_CV_TRUE_( local_shared_ptr, T, local_shared_ptr, U ) \ + TEST_CV_TRUE_( shared_ptr, T, local_shared_ptr, U ) + +#define TEST_CV_FALSE( T, U ) \ + TEST_CV_FALSE_( local_shared_ptr, T, local_shared_ptr, U ) \ + TEST_CV_FALSE_( shared_ptr, T, local_shared_ptr, U ) + +int main() +{ +#if !defined( BOOST_SP_NO_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(); +} diff --git a/test/lsp_convertible_test2.cpp b/test/lsp_convertible_test2.cpp new file mode 100644 index 0000000..2104b4e --- /dev/null +++ b/test/lsp_convertible_test2.cpp @@ -0,0 +1,108 @@ +#include + +// lsp_convertible_test.cpp +// +// Copyright 2012, 2017 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 +#include +#include +#include +#include + +// + +class X; + +class B +{ +}; + +class D: public B +{ +}; + +using boost::is_convertible; + +#define TEST_CV_TRUE_( S1, T, S2, U ) \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); + +#define TEST_CV_FALSE_( S1, T, S2, U ) \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); + +using boost::local_shared_ptr; +using boost::shared_ptr; +using boost::weak_ptr; + +#define TEST_CV_TRUE( T, U ) \ + TEST_CV_TRUE_( local_shared_ptr, T, shared_ptr, U ) \ + TEST_CV_TRUE_( local_shared_ptr, T, weak_ptr, U ) + +#define TEST_CV_FALSE( T, U ) \ + TEST_CV_FALSE_( local_shared_ptr, T, shared_ptr, U ) \ + TEST_CV_FALSE_( local_shared_ptr, T, weak_ptr, U ) + +int main() +{ +#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) + + 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(); +} diff --git a/test/sp_convertible_test2.cpp b/test/sp_convertible_test2.cpp new file mode 100644 index 0000000..7635d82 --- /dev/null +++ b/test/sp_convertible_test2.cpp @@ -0,0 +1,108 @@ +#include + +// sp_convertible_test2.cpp +// +// Copyright 2012, 2017 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 +#include +#include +#include + +// + +class X; + +class B +{ +}; + +class D: public B +{ +}; + +using boost::is_convertible; + +#define TEST_CV_TRUE_( S1, T, S2, U ) \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == true )); + +#define TEST_CV_FALSE_( S1, T, S2, U ) \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); \ + BOOST_TEST(( is_convertible< S1, S2 >::value == false )); + +using boost::shared_ptr; +using boost::weak_ptr; + +#define TEST_CV_TRUE( T, U ) \ + TEST_CV_TRUE_( shared_ptr, T, shared_ptr, U ) \ + TEST_CV_TRUE_( shared_ptr, T, weak_ptr, U ) \ + TEST_CV_TRUE_( weak_ptr, T, weak_ptr, U ) + +#define TEST_CV_FALSE( T, U ) \ + TEST_CV_FALSE_( shared_ptr, T, shared_ptr, U ) \ + TEST_CV_FALSE_( shared_ptr, T, weak_ptr, U ) \ + TEST_CV_FALSE_( weak_ptr, T, weak_ptr, U ) + +int main() +{ +#if !defined( BOOST_SP_NO_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(); +}