diff options
Diffstat (limited to 'src/boost/libs/tti/test')
104 files changed, 3044 insertions, 0 deletions
diff --git a/src/boost/libs/tti/test/Jamfile.v2 b/src/boost/libs/tti/test/Jamfile.v2 new file mode 100644 index 00000000..e63ab201 --- /dev/null +++ b/src/boost/libs/tti/test/Jamfile.v2 @@ -0,0 +1,435 @@ + +# (C) Copyright Edward Diener 2011,2012 +# Use, modification and distribution are subject to 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). +# +# Tti testing Jamfile +# + +import testing ; + +project tti_tests : requirements <warnings>on + <toolset>gcc:<warnings>all + <toolset>msvc:<warnings>all + <toolset>gcc-4.3.0:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.4.0:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.4.7:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.5.0:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.5.0:<linkflags>"-Wl,--enable-auto-import" + <toolset>gcc-4.5.2:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.6.0:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.6.1:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.6.2:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.6.3:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.7.0:<cxxflags>-Wno-variadic-macros + <toolset>gcc-4.7.2:<cxxflags>-Wno-variadic-macros + ; + +# +# Member functions composite syntax +# +alias ttimfsig + : + [ run test_has_member.cpp ] + [ compile test_has_member_compile.cpp ] + [ compile-fail test_has_member_fail.cpp ] + [ compile-fail test_has_member_fail2.cpp ] + [ compile-fail test_has_member_fail3.cpp ] + ; + +# +# Member functions composite syntax, cv-qualified +# +alias ttimfsigcv + : + [ run test_has_member_cv.cpp ] + [ compile test_has_member_cv_compile.cpp ] + [ compile-fail test_has_member_cv_fail.cpp ] + [ compile-fail test_has_member_cv_fail2.cpp ] + [ compile-fail test_has_member_cv_fail3.cpp ] + [ compile-fail test_has_member_cv_fail4.cpp ] + [ compile-fail test_has_member_cv_fail5.cpp ] + ; + +# +# Member data +# +alias ttimd + : + [ run test_has_mem_data.cpp ] + [ run test_has_mem_data2.cpp ] + [ compile test_has_mem_data_compile.cpp ] + [ compile-fail test_has_mem_data_fail.cpp ] + [ compile-fail test_has_mem_data_fail2.cpp ] + [ compile-fail test_has_mem_data_fail3.cpp ] + ; + +# +# Member functions specific syntax +# +alias ttimfn + : + [ run test_has_mem_fun.cpp ] + [ compile test_has_mem_fun_compile.cpp ] + [ compile-fail test_has_mem_fun_fail.cpp ] + [ compile-fail test_has_mem_fun_fail2.cpp ] + [ compile-fail test_has_mem_fun_fail3.cpp ] + ; + +# +# Member functions specific syntax, cv-qualified +# +alias ttimfncv + : + [ run test_has_mem_fun_cv.cpp ] + [ compile test_has_mem_fun_cv_compile.cpp ] + [ compile-fail test_has_mem_fun_cv_fail.cpp ] + [ compile-fail test_has_mem_fun_cv_fail2.cpp ] + [ compile-fail test_has_mem_fun_cv_fail3.cpp ] + [ compile-fail test_has_mem_fun_cv_fail4.cpp ] + [ compile-fail test_has_mem_fun_cv_fail5.cpp ] + [ compile-fail test_has_mem_fun_cv_fail6.cpp ] + ; + +# +# Static member functions composite syntax +# +alias ttismfsig + : + [ run test_has_static_member.cpp ] + [ compile test_has_static_member_compile.cpp ] + [ compile-fail test_has_static_member_fail.cpp ] + [ compile-fail test_has_static_member_fail2.cpp ] + ; + +# +# Static member data +# +alias ttismd + : + [ run test_has_static_mem_data.cpp ] + [ compile test_has_static_mem_data_compile.cpp ] + [ compile-fail test_has_static_mem_data_fail.cpp ] + [ compile-fail test_has_static_mem_data_fail2.cpp ] + [ compile-fail test_has_static_mem_data_fail3.cpp ] + ; + +# +# Static member functions +# +alias ttismfn + : + [ run test_has_static_mem_fun.cpp ] + [ compile test_has_static_mem_fun_compile.cpp ] + [ compile-fail test_has_static_mem_fun_fail.cpp ] + [ compile-fail test_has_static_mem_fun_fail2.cpp ] + ; + +# +# Member or static member data +# +alias ttidata + : + [ run test_has_data.cpp ] + [ compile test_has_data_compile.cpp ] + [ compile-fail test_has_data_fail.cpp ] + [ compile-fail test_has_data_fail2.cpp ] + [ compile-fail test_has_data_fail3.cpp ] + [ compile-fail test_has_data_fail4.cpp ] + [ compile-fail test_has_data_fail5.cpp ] + [ compile-fail test_has_data_fail6.cpp ] + ; + +# +# Member or static member function +# +alias ttifun + : + [ run test_has_fun.cpp ] + [ compile test_has_fun_compile.cpp ] + [ compile-fail test_has_fun_fail.cpp ] + [ compile-fail test_has_fun_fail2.cpp ] + [ compile-fail test_has_fun_fail3.cpp ] + [ compile-fail test_has_fun_fail4.cpp ] + [ compile-fail test_has_fun_fail5.cpp ] + ; + +# +# Templates +# +alias ttitmp + : + [ run test_has_template.cpp : : : <define>BOOST_PP_VARIADICS=0 ] + [ compile test_has_template_compile.cpp : <define>BOOST_PP_VARIADICS=0 ] + [ compile-fail test_has_template_fail.cpp : <define>BOOST_PP_VARIADICS=0 ] + [ compile-fail test_has_template_fail2.cpp : <define>BOOST_PP_VARIADICS=0 ] + [ compile-fail test_has_template_fail3.cpp : <define>BOOST_PP_VARIADICS=0 ] + [ compile-fail test_has_template_fail4.cpp : <define>BOOST_PP_VARIADICS=0 ] + ; + +# +# Templates, check params +# +alias ttitmpcp + : + [ run test_has_template_cp.cpp : : : <define>BOOST_PP_VARIADICS=0 ] + [ compile test_has_template_cp_compile.cpp : <define>BOOST_PP_VARIADICS=0 ] + [ compile-fail test_has_template_cp_fail.cpp : <define>BOOST_PP_VARIADICS=0 ] + [ compile-fail test_has_template_cp_fail2.cpp : <define>BOOST_PP_VARIADICS=0 ] + [ compile-fail test_has_template_cp_fail3.cpp : <define>BOOST_PP_VARIADICS=0 ] + [ compile-fail test_has_template_cp_fail4.cpp : <define>BOOST_PP_VARIADICS=0 ] + ; + +# +# Type +# +alias ttity + : + [ run test_has_type.cpp ] + [ compile test_has_type_compile.cpp ] + [ compile-fail test_has_type_fail.cpp ] + [ compile-fail test_has_type_fail2.cpp ] + [ compile-fail test_has_type_fail3.cpp ] + [ run test_has_type_ct.cpp ] + [ compile test_has_type_ct_compile.cpp ] + [ compile-fail test_has_type_ct_fail.cpp ] + [ compile-fail test_has_type_ct_fail2.cpp ] + [ compile-fail test_has_type_ct_fail3.cpp ] + [ compile-fail test_has_type_ct_fail4.cpp ] + [ compile-fail test_has_type_ct_fail5.cpp ] + ; + +# +# Nested type +# +alias ttimemty + : + [ run test_mem_type.cpp ] + [ compile test_mem_type_compile.cpp ] + ; +# +# All of tti, non-variadic macros +# +alias ttinovm : ttimfsig ttimfsigcv ttimd ttimfn ttimfncv ttismfsig ttismd ttismfn ttidata ttifun ttitmp ttitmpcp ttity ttimemty ; + +alias ttitmpv : : + <toolset>gcc + <toolset-gcc:version>3.4.2 + ; + +alias ttitmpv : : + <toolset>gcc + <toolset-gcc:version>3.4.5 + ; + +alias ttitmpv : : + <toolset>gcc + <toolset-gcc:version>4.1.2 + ; + +alias ttitmpv : : + <toolset>gcc + <toolset-gcc:version>4.2.1 + ; + +# +# Templates, variadic macro +# +alias ttitmpv + : + [ run test_has_template.cpp : : : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_v ] + [ compile test_has_template_compile.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_compile_v ] + [ compile-fail test_has_template_fail.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_fail_v ] + [ compile-fail test_has_template_fail2.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_fail2_v ] + [ compile-fail test_has_template_fail3.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_fail3_v ] + [ compile-fail test_has_template_fail4.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_fail4_v ] + ; + +alias ttitmpcpv : : + <toolset>gcc + <toolset-gcc:version>3.4.2 + ; + +alias ttitmpcpv : : + <toolset>gcc + <toolset-gcc:version>3.4.5 + ; + +alias ttitmpcpv : : + <toolset>gcc + <toolset-gcc:version>4.1.2 + ; + +alias ttitmpcpv : : + <toolset>gcc + <toolset-gcc:version>4.2.1 + ; + +# +# Templates, variadic macro, check params, non-variadic syntax +# +alias ttitmpcpv + : + [ run test_has_template_cp.cpp : : : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_cp_v ] + [ compile test_has_template_cp_compile.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_cp_compile_v ] + [ compile-fail test_has_template_cp_fail.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_cp_fail_v ] + [ compile-fail test_has_template_cp_fail2.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_cp_fail2_v ] + [ compile-fail test_has_template_cp_fail3.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_cp_fail3_v ] + [ compile-fail test_has_template_cp_fail4.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 : + test_has_template_cp_fail4_v ] + ; + +alias ttitmpcpvm : : + <toolset>gcc + <toolset-gcc:version>3.4.2 + ; + +alias ttitmpcpvm : : + <toolset>gcc + <toolset-gcc:version>3.4.5 + ; + +alias ttitmpcpvm : : + <toolset>gcc + <toolset-gcc:version>4.1.2 + ; + +alias ttitmpcpvm : : + <toolset>gcc + <toolset-gcc:version>4.2.1 + ; + +# +# Templates, variadic macro, check params, variadic syntax +# +alias ttitmpcpvm + : + [ run test_vm_has_template_cp.cpp : : : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 ] + [ compile test_vm_has_template_cp_compile.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 ] + [ compile-fail test_vm_has_template_cp_fail.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 ] + [ compile-fail test_vm_has_template_cp_fail2.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 ] + [ compile-fail test_vm_has_template_cp_fail3.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 ] + [ compile-fail test_vm_has_template_cp_fail4.cpp : + <toolset>gcc:<cxxflags>-std=c++0x + <toolset>gcc-4.3.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.0:<cxxflags>-U__STRICT_ANSI__ + <toolset>gcc-4.4.7:<cxxflags>-U__STRICT_ANSI__ + <define>BOOST_PP_VARIADICS=1 ] + ; + +# +# Templates, non-variadic macro +# +alias ttitemplate : ttitmp ttitmpcp ; + +# +# Templates, variadic macro +# +alias ttivm : ttitmpv ttitmpcpv ttitmpcpvm ; + +# +# All templates +# +alias ttitemplate_all : ttitemplate ttivm ; + +# +# All tests +# +alias tti : ttinovm ttivm ; diff --git a/src/boost/libs/tti/test/test_has_data.cpp b/src/boost/libs/tti/test/test_has_data.cpp new file mode 100644 index 00000000..4c705717 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data.cpp @@ -0,0 +1,37 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_data.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(AnInt)<AType,int>::value)); + BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(SomeStaticData)<AnotherType,float>::value)); + BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(AnInt)<AnotherType,long>::value)); + BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(DSMember)<AType,short>::value)); + BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(aMember)<AnotherType,bool>::value)); + BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(aMember)<AnotherType,int>::value)); + BOOST_TEST((DCMember<AnotherType,bool>::value)); + BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(someDataMember)<AType,short>::value)); + BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(IntBT)<AType,AType::BType>::value)); + BOOST_TEST((DStatName<AnotherType,AType::AStructType>::value)); + BOOST_TEST((DNestedData<AType,AType::BType::CType>::value)); + BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(CIntValue)<AnotherType,const int>::value)); + BOOST_TEST((DAOther<AnotherType,AType>::value)); + BOOST_TEST((BOOST_TTI_HAS_DATA_GEN(ONestStr)<AnotherType,AType::AStructType>::value)); + + // Passing non-class enclosing type will return false + + BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(IntBT)<unsigned long,AType::BType>::value)); + BOOST_TEST((!DCMember<AnotherType *,bool>::value)); + BOOST_TEST((!DCMember<AnotherType &,bool>::value)); + BOOST_TEST((!BOOST_TTI_HAS_DATA_GEN(AnInt)<int **,long>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_data.hpp b/src/boost/libs/tti/test/test_has_data.hpp new file mode 100644 index 00000000..c48dc1c2 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data.hpp @@ -0,0 +1,26 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_HAS_DATA_HPP) +#define TEST_HAS_DATA_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_data.hpp> + +BOOST_TTI_HAS_DATA(AnInt) +BOOST_TTI_HAS_DATA(DSMember) +BOOST_TTI_HAS_DATA(aMember) +BOOST_TTI_TRAIT_HAS_DATA(DCMember,cMem) +BOOST_TTI_HAS_DATA(someDataMember) +BOOST_TTI_HAS_DATA(CIntValue) +BOOST_TTI_HAS_DATA(SomeStaticData) +BOOST_TTI_TRAIT_HAS_DATA(DStatName,AnStat) +BOOST_TTI_HAS_DATA(IntBT) +BOOST_TTI_TRAIT_HAS_DATA(DNestedData,NestedCT) +BOOST_TTI_TRAIT_HAS_DATA(DAOther,OtherAT) +BOOST_TTI_HAS_DATA(ONestStr) + +#endif // TEST_HAS_DATA_HPP diff --git a/src/boost/libs/tti/test/test_has_data_compile.cpp b/src/boost/libs/tti/test/test_has_data_compile.cpp new file mode 100644 index 00000000..4480d033 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data_compile.cpp @@ -0,0 +1,36 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_DATA_GEN(aMember)<AType,long> aVar; + BOOST_TTI_HAS_DATA_GEN(SomeStaticData)<AnotherType,long> aVar2; + BOOST_TTI_HAS_DATA_GEN(someDataMember)<AnotherType,double> aVar3; + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(AnInt)<AType,int>)); + BOOST_MPL_ASSERT_NOT((BOOST_TTI_HAS_DATA_GEN(SomeStaticData)<AnotherType,float>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(AnInt)<AnotherType,long>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(DSMember)<AType,short>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(aMember)<AnotherType,bool>)); + BOOST_MPL_ASSERT_NOT((BOOST_TTI_HAS_DATA_GEN(aMember)<AnotherType,int>)); + BOOST_MPL_ASSERT((DCMember<AnotherType,bool>)); + BOOST_MPL_ASSERT_NOT((BOOST_TTI_HAS_DATA_GEN(someDataMember)<AType,short>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(IntBT)<AType,AType::BType>)); + BOOST_MPL_ASSERT((DStatName<AnotherType,AType::AStructType>)); + BOOST_MPL_ASSERT((DNestedData<AType,AType::BType::CType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(CIntValue)<AnotherType,const int>)); + BOOST_MPL_ASSERT((DAOther<AnotherType,AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(ONestStr)<AnotherType,AType::AStructType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_data_fail.cpp b/src/boost/libs/tti/test/test_has_data_fail.cpp new file mode 100644 index 00000000..edff6235 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // someDataMember does not exist at all + + BOOST_MPL_ASSERT(( BOOST_TTI_HAS_DATA_GEN(someDataMember)<AType,short> )); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_data_fail2.cpp b/src/boost/libs/tti/test/test_has_data_fail2.cpp new file mode 100644 index 00000000..6383c36e --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data_fail2.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong data signature for aMember + + BOOST_MPL_ASSERT(( BOOST_TTI_HAS_DATA_GEN(aMember)<AnotherType,int> )); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_data_fail3.cpp b/src/boost/libs/tti/test/test_has_data_fail3.cpp new file mode 100644 index 00000000..a5567cdf --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data_fail3.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_data.hpp" + +int main() + { + + // Data signature has type which does not exist + + BOOST_TTI_HAS_DATA_GEN(aMember)<AnotherType,AType::NTHType> aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_data_fail4.cpp b/src/boost/libs/tti/test/test_has_data_fail4.cpp new file mode 100644 index 00000000..fbe5fee0 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data_fail4.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // SomeStaticData does not exist at all + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(SomeStaticData)<AnotherType,float>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_data_fail5.cpp b/src/boost/libs/tti/test/test_has_data_fail5.cpp new file mode 100644 index 00000000..a2470014 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data_fail5.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong enclosing type for DSMember + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_DATA_GEN(DSMember)<AnotherType,short>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_data_fail6.cpp b/src/boost/libs/tti/test/test_has_data_fail6.cpp new file mode 100644 index 00000000..95a2a9f5 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_data_fail6.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_data.hpp" + +int main() + { + + // Data signature has type which does not exist + + BOOST_TTI_HAS_DATA_GEN(DSMember)<NoType,short> aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_fun.cpp b/src/boost/libs/tti/test/test_has_fun.cpp new file mode 100644 index 00000000..8a4f7216 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_fun.cpp @@ -0,0 +1,33 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_fun.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((BOOST_TTI_HAS_FUNCTION_GEN(VoidFunction)<AType,void>::value)); + BOOST_TEST((HaveTheSIntFunction<AType,int,boost::mpl::vector<long,double> >::value)); + BOOST_TEST((BOOST_TTI_HAS_FUNCTION_GEN(TSFunction)<AnotherType,AType::AStructType,boost::mpl::vector<AType::AnIntType,double> >::value)); + BOOST_TEST((FunctionReturningInt<AType,int>::value)); + BOOST_TEST((!Pickedname<AnotherType,void>::value)); + BOOST_TEST((!TheTIntFunction<AType,AType,boost::mpl::vector<long,double> >::value)); + BOOST_TEST((FunctionReturningInt<AnotherType,double,boost::mpl::vector<int> >::value)); + BOOST_TEST((BOOST_TTI_HAS_FUNCTION_GEN(aFunction)<AnotherType,AType,boost::mpl::vector<int> >::value)); + BOOST_TEST((AnotherIntFunction<AnotherType,int,boost::mpl::vector<AType> >::value)); + BOOST_TEST((BOOST_TTI_HAS_FUNCTION_GEN(sFunction)<AnotherType,AType::AnIntType,boost::mpl::vector<int,long,double> >::value)); + BOOST_TEST((!BOOST_TTI_HAS_FUNCTION_GEN(someFunctionMember)<AnotherType,AType,boost::mpl::vector<long,int> >::value)); + BOOST_TEST((TheTIntFunction<AnotherType,AType,boost::mpl::vector<long,double> >::value)); + + // Passing non-class enclosing type will return false + + BOOST_TEST((!HaveTheSIntFunction<long,int,boost::mpl::vector<long,double> >::value)); + BOOST_TEST((!BOOST_TTI_HAS_FUNCTION_GEN(TSFunction)<AnotherType **,AType::AStructType,boost::mpl::vector<AType::AnIntType,double> >::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_fun.hpp b/src/boost/libs/tti/test/test_has_fun.hpp new file mode 100644 index 00000000..dd4a7bb5 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_fun.hpp @@ -0,0 +1,24 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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). + +#if !defined(BOOST_TEST_HAS_FUNCTION_HPP) +#define BOOST_TEST_HAS_FUNCTION_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_function.hpp> + +BOOST_TTI_HAS_FUNCTION(VoidFunction) +BOOST_TTI_TRAIT_HAS_FUNCTION(TheTIntFunction,TIntFunction) +BOOST_TTI_TRAIT_HAS_FUNCTION(FunctionReturningInt,IntFunction) +BOOST_TTI_HAS_FUNCTION(aFunction) +BOOST_TTI_TRAIT_HAS_FUNCTION(AnotherIntFunction,anotherFunction) +BOOST_TTI_TRAIT_HAS_FUNCTION(Pickedname,SomeStaticFunction) +BOOST_TTI_HAS_FUNCTION(sFunction) +BOOST_TTI_HAS_FUNCTION(someFunctionMember) +BOOST_TTI_TRAIT_HAS_FUNCTION(HaveTheSIntFunction,SIntFunction) +BOOST_TTI_HAS_FUNCTION(TSFunction) + +#endif // BOOST_TEST_HAS_FUNCTION_HPP diff --git a/src/boost/libs/tti/test/test_has_fun_compile.cpp b/src/boost/libs/tti/test/test_has_fun_compile.cpp new file mode 100644 index 00000000..7f0e36c9 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_fun_compile.cpp @@ -0,0 +1,33 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + TheTIntFunction<AType,void,boost::mpl::vector<long,double> > aVar; + BOOST_TTI_HAS_FUNCTION_GEN(someFunctionMember)<AnotherType,double,boost::mpl::vector<short,short,long,int> > aVar2; + Pickedname<AnotherType,AType,boost::mpl::vector<long,long> > aVar3; + + // Compile time asserts + + BOOST_MPL_ASSERT((TheTIntFunction<AnotherType,AType,boost::mpl::vector<long,double> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_FUNCTION_GEN(VoidFunction)<AType,void>)); + BOOST_MPL_ASSERT((FunctionReturningInt<AType,int>)); + BOOST_MPL_ASSERT((FunctionReturningInt<AnotherType,double,boost::mpl::vector<int> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_FUNCTION_GEN(TSFunction)<AnotherType,AType::AStructType,boost::mpl::vector<AType::AnIntType,double> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_FUNCTION_GEN(aFunction)<AnotherType,AType,boost::mpl::vector<int> >)); + BOOST_MPL_ASSERT((AnotherIntFunction<AnotherType,int,boost::mpl::vector<AType> >)); + BOOST_MPL_ASSERT((HaveTheSIntFunction<AType,int,boost::mpl::vector<long,double> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_FUNCTION_GEN(sFunction)<AnotherType,AType::AnIntType,boost::mpl::vector<int,long,double> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_fun_fail.cpp b/src/boost/libs/tti/test/test_has_fun_fail.cpp new file mode 100644 index 00000000..d80b6411 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_fun_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong function signature for sFunction + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_FUNCTION_GEN(sFunction)<AnotherType,AType::AnIntType,boost::mpl::vector<short,long,double> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_fun_fail2.cpp b/src/boost/libs/tti/test/test_has_fun_fail2.cpp new file mode 100644 index 00000000..bbc465bb --- /dev/null +++ b/src/boost/libs/tti/test/test_has_fun_fail2.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_fun.hpp" + +int main() + { + + // Function signature has type which does not exist + + BOOST_TTI_HAS_FUNCTION_GEN(sFunction)<NVType,AType::AnIntType,boost::mpl::vector<short,long,double> > aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_fun_fail3.cpp b/src/boost/libs/tti/test/test_has_fun_fail3.cpp new file mode 100644 index 00000000..9d830f5f --- /dev/null +++ b/src/boost/libs/tti/test/test_has_fun_fail3.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong function signature for SIntFunction + + BOOST_MPL_ASSERT((HaveTheSIntFunction<AType,int,boost::mpl::vector<float,double> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_fun_fail4.cpp b/src/boost/libs/tti/test/test_has_fun_fail4.cpp new file mode 100644 index 00000000..54e0dbde --- /dev/null +++ b/src/boost/libs/tti/test/test_has_fun_fail4.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_fun.hpp" + +int main() + { + + // Function signature has type which does not exist + + BOOST_TTI_HAS_FUNCTION_GEN(TSFunction)<AnotherType,AType::AClassType,boost::mpl::vector<AType::AnIntType,double> > aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_fun_fail5.cpp b/src/boost/libs/tti/test/test_has_fun_fail5.cpp new file mode 100644 index 00000000..3eea9daf --- /dev/null +++ b/src/boost/libs/tti/test/test_has_fun_fail5.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2012,2013 +// Use, modification and distribution are subject to 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 "test_has_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // With default parameters you must still specify complete function prototype + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_FUNCTION_GEN(aFunction)<AnotherType,AType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_data.cpp b/src/boost/libs/tti/test/test_has_mem_data.cpp new file mode 100644 index 00000000..505862c0 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_data.cpp @@ -0,0 +1,33 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_data.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(AnInt)<AType,int>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(AnInt)<AnotherType,long>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(aMember)<AnotherType,bool>::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_DATA_GEN(aMember)<AnotherType,int>::value)); + BOOST_TEST((CMember<AnotherType,bool>::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_DATA_GEN(someDataMember)<AType,short>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(IntBT)<AType,AType::BType>::value)); + BOOST_TEST((NestedData<AType,AType::BType::CType>::value)); + BOOST_TEST((AOther<AnotherType,AType>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(ONestStr)<AnotherType,AType::AStructType>::value)); + + // Test enclosing class as non-class type + + BOOST_TEST((!CMember<bool,bool>::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_DATA_GEN(AnInt)<int,long>::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_DATA_GEN(IntBT)<AType &,AType::BType>::value)); + BOOST_TEST((!AOther<double *,AType>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_mem_data.hpp b/src/boost/libs/tti/test/test_has_mem_data.hpp new file mode 100644 index 00000000..1238c0d8 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_data.hpp @@ -0,0 +1,22 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_HAS_MEMBER_DATA_HPP) +#define TEST_HAS_MEMBER_DATA_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_member_data.hpp> + +BOOST_TTI_HAS_MEMBER_DATA(AnInt) +BOOST_TTI_HAS_MEMBER_DATA(aMember) +BOOST_TTI_TRAIT_HAS_MEMBER_DATA(CMember,cMem) +BOOST_TTI_HAS_MEMBER_DATA(someDataMember) +BOOST_TTI_HAS_MEMBER_DATA(IntBT) +BOOST_TTI_TRAIT_HAS_MEMBER_DATA(NestedData,NestedCT) +BOOST_TTI_TRAIT_HAS_MEMBER_DATA(AOther,OtherAT) +BOOST_TTI_HAS_MEMBER_DATA(ONestStr) + +#endif // TEST_HAS_MEMBER_DATA_HPP diff --git a/src/boost/libs/tti/test/test_has_mem_data2.cpp b/src/boost/libs/tti/test/test_has_mem_data2.cpp new file mode 100644 index 00000000..a39cc0d5 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_data2.cpp @@ -0,0 +1,26 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_mem_data.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(AnInt)<int AType::*>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(AnInt)<long AnotherType::*>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(aMember)<bool AnotherType::*>::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_DATA_GEN(aMember)<int AnotherType::*>::value)); + BOOST_TEST((CMember<bool AnotherType::*>::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_DATA_GEN(someDataMember)<short AType::*>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(IntBT)<AType::BType AType::*>::value)); + BOOST_TEST((NestedData<AType::BType::CType AType::*>::value)); + BOOST_TEST((AOther<AType AnotherType::*>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_DATA_GEN(ONestStr)<AType::AStructType AnotherType::*>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_mem_data_compile.cpp b/src/boost/libs/tti/test/test_has_mem_data_compile.cpp new file mode 100644 index 00000000..e5d31f18 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_data_compile.cpp @@ -0,0 +1,31 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_MEMBER_DATA_GEN(aMember)<AType,long> aVar; + BOOST_TTI_HAS_MEMBER_DATA_GEN(someDataMember)<AnotherType,double> aVar2; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_DATA_GEN(AnInt)<AType,int>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_DATA_GEN(AnInt)<AnotherType,long>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_DATA_GEN(aMember)<AnotherType,bool>)); + BOOST_MPL_ASSERT((CMember<AnotherType,bool>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_DATA_GEN(IntBT)<AType,AType::BType>)); + BOOST_MPL_ASSERT((NestedData<AType,AType::BType::CType>)); + BOOST_MPL_ASSERT((AOther<AnotherType,AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_DATA_GEN(ONestStr)<AnotherType,AType::AStructType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_data_fail.cpp b/src/boost/libs/tti/test/test_has_mem_data_fail.cpp new file mode 100644 index 00000000..50d059e4 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_data_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // someDataMember does not exist at all + + BOOST_MPL_ASSERT(( BOOST_TTI_HAS_MEMBER_DATA_GEN(someDataMember)<AType,short> )); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_data_fail2.cpp b/src/boost/libs/tti/test/test_has_mem_data_fail2.cpp new file mode 100644 index 00000000..b0f782ab --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_data_fail2.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong data signature for aMember + + BOOST_MPL_ASSERT(( BOOST_TTI_HAS_MEMBER_DATA_GEN(aMember)<AnotherType,int> )); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_data_fail3.cpp b/src/boost/libs/tti/test/test_has_mem_data_fail3.cpp new file mode 100644 index 00000000..eeefccab --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_data_fail3.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_data.hpp" + +int main() + { + + // Data signature has type which does not exist + + BOOST_TTI_HAS_MEMBER_DATA_GEN(aMember)<AnotherType,AType::NTHType> aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun.cpp b/src/boost/libs/tti/test/test_has_mem_fun.cpp new file mode 100644 index 00000000..ce1488f5 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun.cpp @@ -0,0 +1,30 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(VoidFunction)<AType,void>::value)); + BOOST_TEST((FunctionReturningInt<AType,int>::value)); + BOOST_TEST((FunctionReturningInt<AnotherType,double,boost::mpl::vector<int> >::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(aFunction)<AnotherType,AType,boost::mpl::vector<int> >::value)); + BOOST_TEST((AnotherIntFunction<AnotherType,int,boost::mpl::vector<AType> >::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AnotherType,AType::AnIntType,boost::mpl::vector<int,long,double> >::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(someFunctionMember)<AnotherType,AType,boost::mpl::vector<long,int> >::value)); + + // Test enclosing class as non-class type + + BOOST_TEST((!AnotherIntFunction<short,int,boost::mpl::vector<AType> >::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(VoidFunction)<unsigned,void>::value)); + BOOST_TEST((!BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AnotherType *,AType::AnIntType,boost::mpl::vector<int,long,double> >::value)); + BOOST_TEST((!FunctionReturningInt<float ***,int>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun.hpp b/src/boost/libs/tti/test/test_has_mem_fun.hpp new file mode 100644 index 00000000..84ce95fc --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun.hpp @@ -0,0 +1,35 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_HAS_MEMBER_FUNCTION_HPP) +#define TEST_HAS_MEMBER_FUNCTION_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_member_function.hpp> + +BOOST_TTI_HAS_MEMBER_FUNCTION(VoidFunction) +BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(FunctionReturningInt,IntFunction) +BOOST_TTI_HAS_MEMBER_FUNCTION(aFunction) +BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(AnotherIntFunction,anotherFunction) +BOOST_TTI_HAS_MEMBER_FUNCTION(sFunction) +BOOST_TTI_HAS_MEMBER_FUNCTION(someFunctionMember) + +BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(AskIfConst,WFunction) // const +BOOST_TTI_HAS_MEMBER_FUNCTION(AnotherConstFunction) // const +BOOST_TTI_HAS_MEMBER_FUNCTION(AConstFunction) // const +BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(StillTest,StillSame) // const + +BOOST_TTI_HAS_MEMBER_FUNCTION(AVolatileFunction) // volatile +BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(Volly,VolFunction) // volatile +BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(AnVol,AnotherVolatileFunction) // volatile +BOOST_TTI_HAS_MEMBER_FUNCTION(StillVolatile) // volatile + +BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(CVBoth,ACVFunction) // const volatile +BOOST_TTI_HAS_MEMBER_FUNCTION(ConstVolFunction) // const volatile +BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION(CVAnother,AnotherConstVolatileFunction) // const volatile +BOOST_TTI_HAS_MEMBER_FUNCTION(StillCV) // const volatile + +#endif // TEST_HAS_MEMBER_FUNCTION_HPP diff --git a/src/boost/libs/tti/test/test_has_mem_fun_compile.cpp b/src/boost/libs/tti/test/test_has_mem_fun_compile.cpp new file mode 100644 index 00000000..58a65fdb --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_compile.cpp @@ -0,0 +1,28 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(someFunctionMember)<AnotherType,double,boost::mpl::vector<short,short,long,int> > aVar3; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(VoidFunction)<AType,void>)); + BOOST_MPL_ASSERT((FunctionReturningInt<AType,int>)); + BOOST_MPL_ASSERT((FunctionReturningInt<AnotherType,double,boost::mpl::vector<int> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(aFunction)<AnotherType,AType,boost::mpl::vector<int> >)); + BOOST_MPL_ASSERT((AnotherIntFunction<AnotherType,int,boost::mpl::vector<AType> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AnotherType,AType::AnIntType,boost::mpl::vector<int,long,double> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_cv.cpp b/src/boost/libs/tti/test/test_has_mem_fun_cv.cpp new file mode 100644 index 00000000..adb6c97e --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_cv.cpp @@ -0,0 +1,45 @@ + +// (C) Copyright Edward Diener 2012 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + // Use const enclosing type + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AConstFunction)<const AType,double,boost::mpl::vector<long,char> >::value)); + BOOST_TEST((StillTest<const AnotherType,AType,boost::mpl::vector<int> >::value)); + + // Use const_qualified + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AnotherConstFunction)<AnotherType,int,boost::mpl::vector<AType *, short>,boost::function_types::const_qualified>::value)); + BOOST_TEST((AskIfConst<AType,void,boost::mpl::vector<float,double>,boost::function_types::const_qualified>::value)); + + // Use volatile enclosing type + + BOOST_TEST((AnVol<volatile AnotherType,int,boost::mpl::vector<AType *,short> >::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AVolatileFunction)<volatile AType,double,boost::mpl::vector<long,char> >::value)); + + // Use volatile_qualified + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillVolatile)<AnotherType,bool,boost::mpl::vector<int>,boost::function_types::volatile_qualified>::value)); + BOOST_TEST((Volly<AType,void,boost::mpl::vector<float,double>,boost::function_types::volatile_qualified>::value)); + + // Use const volatile enclosing type + + BOOST_TEST((CVAnother<const volatile AnotherType,int,boost::mpl::vector<AType *,short> >::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillCV)<const volatile AnotherType,short,boost::mpl::vector<int> >::value)); + + // Use cv_qualified + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(ConstVolFunction)<AType,void,boost::mpl::vector<float,double>,boost::function_types::cv_qualified>::value)); + BOOST_TEST((CVBoth<AType,double,boost::mpl::vector<long,char>,boost::function_types::cv_qualified>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_cv_compile.cpp b/src/boost/libs/tti/test/test_has_mem_fun_cv_compile.cpp new file mode 100644 index 00000000..f424cce4 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_cv_compile.cpp @@ -0,0 +1,49 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors even if the member function does not exist + + BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(someFunctionMember)<AnotherType,double,boost::mpl::vector<short,short,long,int>,boost::function_types::const_qualified> aVar1; + + // Use const enclosing type + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AnotherConstFunction)<const AnotherType,int,boost::mpl::vector<AType *, short> >)); + BOOST_MPL_ASSERT((AskIfConst<const AType,void,boost::mpl::vector<float,double> >)); + + // Use const_qualified + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AConstFunction)<AType,double,boost::mpl::vector<long,char>,boost::function_types::const_qualified>)); + BOOST_MPL_ASSERT((StillTest<AnotherType,AType,boost::mpl::vector<int>,boost::function_types::const_qualified>)); + + // Use volatile enclosing type + + BOOST_MPL_ASSERT((AnVol<volatile AnotherType,int,boost::mpl::vector<AType *,short> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AVolatileFunction)<volatile AType,double,boost::mpl::vector<long,char> >)); + + // Use volatile_qualified + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillVolatile)<AnotherType,bool,boost::mpl::vector<int>,boost::function_types::volatile_qualified>)); + BOOST_MPL_ASSERT((Volly<AType,void,boost::mpl::vector<float,double>,boost::function_types::volatile_qualified>)); + + // Use const volatile enclosing type + + BOOST_MPL_ASSERT((CVAnother<const volatile AnotherType,int,boost::mpl::vector<AType *,short> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillCV)<const volatile AnotherType,short,boost::mpl::vector<int> >)); + + // Use cv_qualified + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(ConstVolFunction)<AType,void,boost::mpl::vector<float,double>,boost::function_types::cv_qualified>)); + BOOST_MPL_ASSERT((CVBoth<AType,double,boost::mpl::vector<long,char>,boost::function_types::cv_qualified>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_cv_fail.cpp b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail.cpp new file mode 100644 index 00000000..97d79466 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Member function is const + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AnotherConstFunction)<AnotherType,int,boost::mpl::vector<AType *, short> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_cv_fail2.cpp b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail2.cpp new file mode 100644 index 00000000..7520b4d4 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail2.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Member function is not const + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(aFunction)<const AnotherType,AType,boost::mpl::vector<int> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_cv_fail3.cpp b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail3.cpp new file mode 100644 index 00000000..4c6bffb7 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail3.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Member function is const volatile + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(ConstVolFunction)<const AType,void,boost::mpl::vector<float,double> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_cv_fail4.cpp b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail4.cpp new file mode 100644 index 00000000..4f807c98 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail4.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Member function is volatile + + BOOST_MPL_ASSERT((Volly<AType,void,boost::mpl::vector<float,double>,boost::function_types::cv_qualified>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_cv_fail5.cpp b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail5.cpp new file mode 100644 index 00000000..518df247 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail5.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // With default parameters you must still specify complete member function prototype + + BOOST_MPL_ASSERT((AskIfConst<const AType,void,boost::mpl::vector<float> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_cv_fail6.cpp b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail6.cpp new file mode 100644 index 00000000..e3e3589a --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_cv_fail6.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // With default parameters you must still specify complete member function prototype + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillCV)<const volatile AnotherType,short>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_fail.cpp b/src/boost/libs/tti/test/test_has_mem_fun_fail.cpp new file mode 100644 index 00000000..8ca70590 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong function signature for sFunction + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AnotherType,AType::AnIntType,boost::mpl::vector<short,long,double> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_fail2.cpp b/src/boost/libs/tti/test/test_has_mem_fun_fail2.cpp new file mode 100644 index 00000000..df3e4b9e --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_fail2.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" + +int main() + { + + // Function signature has type which does not exist + + BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<NVType,AType::AnIntType,boost::mpl::vector<short,long,double> > aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_mem_fun_fail3.cpp b/src/boost/libs/tti/test/test_has_mem_fun_fail3.cpp new file mode 100644 index 00000000..414e02ec --- /dev/null +++ b/src/boost/libs/tti/test/test_has_mem_fun_fail3.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011,2012,2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // With default parameters you must still specify complete member function prototype + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AnotherType,AType::AnIntType,boost::mpl::vector<int> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member.cpp b/src/boost/libs/tti/test/test_has_member.cpp new file mode 100644 index 00000000..4ce46335 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member.cpp @@ -0,0 +1,23 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(VoidFunction)<void (AType::*)()>::value)); + BOOST_TEST(FunctionReturningInt<int (AType::*)()>::value); + BOOST_TEST(FunctionReturningInt<double (AnotherType::*)(int)>::value); + BOOST_TEST(BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(aFunction)<AType (AnotherType::*)(int)>::value); + BOOST_TEST(AnotherIntFunction<int (AnotherType::*)(AType)>::value); + BOOST_TEST(BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AType::AnIntType (AnotherType::*)(int,long,double)>::value); + BOOST_TEST(!BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(someFunctionMember)<AType (AnotherType::*)(long,int)>::value); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_member_compile.cpp b/src/boost/libs/tti/test/test_has_member_compile.cpp new file mode 100644 index 00000000..372ad028 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_compile.cpp @@ -0,0 +1,28 @@ + +// (C) Copyright Edward Diener 2011,2012 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(someFunctionMember)<double (AnotherType::*)(short,short,long,int)> aVar3; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(VoidFunction)<void (AType::*)()>)); + BOOST_MPL_ASSERT((FunctionReturningInt<int (AType::*)()>)); + BOOST_MPL_ASSERT((FunctionReturningInt<double (AnotherType::*)(int)>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(aFunction)<AType (AnotherType::*)(int)>)); + BOOST_MPL_ASSERT((AnotherIntFunction<int (AnotherType::*)(AType)>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AType::AnIntType (AnotherType::*)(int,long,double)>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_cv.cpp b/src/boost/libs/tti/test/test_has_member_cv.cpp new file mode 100644 index 00000000..44db949d --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_cv.cpp @@ -0,0 +1,36 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + // Use const + + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AConstFunction)<double (AType::*)(long,char) const>::value)); + BOOST_TEST((StillTest<AType (AnotherType::*)(int) const>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AnotherConstFunction)<int (AnotherType::*)(AType *, short) const>::value)); + BOOST_TEST((AskIfConst<void (AType::*)(float,double) const>::value)); + + // Use volatile + + BOOST_TEST((AnVol<int (AnotherType::*)(AType *,short) volatile>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AVolatileFunction)<double (AType::*)(long,char) volatile>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillVolatile)<bool (AnotherType::*)(int) volatile>::value)); + BOOST_TEST((Volly<void (AType::*)(float,double) volatile>::value)); + + // Use const volatile + + BOOST_TEST((CVAnother<int (AnotherType::*)(AType *,short) const volatile>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillCV)<short (AnotherType::*)(int) const volatile>::value)); + BOOST_TEST((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(ConstVolFunction)<void (AType::*)(float,double) const volatile>::value)); + BOOST_TEST((CVBoth<double (AType::*)(long,char) const volatile>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_member_cv_compile.cpp b/src/boost/libs/tti/test/test_has_member_cv_compile.cpp new file mode 100644 index 00000000..4a11d222 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_cv_compile.cpp @@ -0,0 +1,40 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(someFunctionMember)<double (AnotherType::*)(short,short,long,int) volatile> aVar1; + + // Use const + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AConstFunction)<double (AType::*)(long,char) const>)); + BOOST_MPL_ASSERT((StillTest<AType (AnotherType::*)(int) const>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AnotherConstFunction)<int (AnotherType::*)(AType *, short) const>)); + BOOST_MPL_ASSERT((AskIfConst<void (AType::*)(float,double) const>)); + + // Use volatile + + BOOST_MPL_ASSERT((AnVol<int (AnotherType::*)(AType *,short) volatile>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AVolatileFunction)<double (AType::*)(long,char) volatile>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillVolatile)<bool (AnotherType::*)(int) volatile>)); + BOOST_MPL_ASSERT((Volly<void (AType::*)(float,double) volatile>)); + + // Use const volatile + + BOOST_MPL_ASSERT((CVAnother<int (AnotherType::*)(AType *,short) const volatile>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillCV)<short (AnotherType::*)(int) const volatile>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(ConstVolFunction)<void (AType::*)(float,double) const volatile>)); + BOOST_MPL_ASSERT((CVBoth<double (AType::*)(long,char) const volatile>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_cv_fail.cpp b/src/boost/libs/tti/test/test_has_member_cv_fail.cpp new file mode 100644 index 00000000..54882478 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_cv_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Member function is not const + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(aFunction)<AType (AnotherType::*)(int) const>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_cv_fail2.cpp b/src/boost/libs/tti/test/test_has_member_cv_fail2.cpp new file mode 100644 index 00000000..a194dc46 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_cv_fail2.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Member function is const + + BOOST_MPL_ASSERT((AskIfConst<void (AType::*)(float,double)>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_cv_fail3.cpp b/src/boost/libs/tti/test/test_has_member_cv_fail3.cpp new file mode 100644 index 00000000..a1a5c3f7 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_cv_fail3.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Member function is const volatile, not volatile + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillCV)<short (AnotherType::*)(int) volatile>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_cv_fail4.cpp b/src/boost/libs/tti/test/test_has_member_cv_fail4.cpp new file mode 100644 index 00000000..8cf40d31 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_cv_fail4.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Member function is volatile, not const + + BOOST_MPL_ASSERT((AnVol<int (AnotherType::*)(AType *,short) const>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_cv_fail5.cpp b/src/boost/libs/tti/test/test_has_member_cv_fail5.cpp new file mode 100644 index 00000000..c973b750 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_cv_fail5.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // With default parameters you must still specify complete member function prototype + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AVolatileFunction)<double (AType::*)(long) volatile>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_fail.cpp b/src/boost/libs/tti/test/test_has_member_fail.cpp new file mode 100644 index 00000000..aeb4f669 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong function signature for sFunction + + BOOST_MPL_ASSERT(( BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AType::AnIntType (AnotherType::*)(short,long,double)> )); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_fail2.cpp b/src/boost/libs/tti/test/test_has_member_fail2.cpp new file mode 100644 index 00000000..53dc4676 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_fail2.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" + +int main() + { + + // Function signature has type which does not exist + + BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AType::AnIntType (NVType::*)(short,long,double)> aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_member_fail3.cpp b/src/boost/libs/tti/test/test_has_member_fail3.cpp new file mode 100644 index 00000000..2e0df8d4 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_member_fail3.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011,2012,2013 +// Use, modification and distribution are subject to 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 "test_has_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // With default parameters you must still specify complete member function prototype + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(sFunction)<AType::AnIntType (AnotherType::*)(int,long)>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_data.cpp b/src/boost/libs/tti/test/test_has_static_mem_data.cpp new file mode 100644 index 00000000..395b6746 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_data.cpp @@ -0,0 +1,25 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_data.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(DSMember)<AType,short>::value)); + BOOST_TEST((!BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(SomeStaticData)<AnotherType,float>::value)); + BOOST_TEST((StatName<AnotherType,AType::AStructType>::value)); + BOOST_TEST((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(CIntValue)<AnotherType,const int>::value)); + + // Passing non-class enclosing type will return false + + BOOST_TEST((!BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(DSMember)<unsigned short,short>::value)); + BOOST_TEST((!StatName<AnotherType *,AType::AStructType>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_data.hpp b/src/boost/libs/tti/test/test_has_static_mem_data.hpp new file mode 100644 index 00000000..8aac6e9f --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_data.hpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_HAS_STATIC_MEMBER_DATA_HPP) +#define TEST_HAS_STATIC_MEMBER_DATA_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_static_member_data.hpp> + +BOOST_TTI_HAS_STATIC_MEMBER_DATA(DSMember) +BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA(StatName,AnStat) +BOOST_TTI_HAS_STATIC_MEMBER_DATA(SomeStaticData) +BOOST_TTI_HAS_STATIC_MEMBER_DATA(CIntValue) + +#endif // TEST_HAS_STATIC_MEMBER_DATA_HPP diff --git a/src/boost/libs/tti/test/test_has_static_mem_data_compile.cpp b/src/boost/libs/tti/test/test_has_static_mem_data_compile.cpp new file mode 100644 index 00000000..a1916444 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_data_compile.cpp @@ -0,0 +1,24 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(SomeStaticData)<AnotherType,long> aVar2; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(DSMember)<AType,short>)); + BOOST_MPL_ASSERT((StatName<AnotherType,AType::AStructType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_data_fail.cpp b/src/boost/libs/tti/test/test_has_static_mem_data_fail.cpp new file mode 100644 index 00000000..25a6a150 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_data_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // SomeStaticData does not exist at all + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(SomeStaticData)<AnotherType,float>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_data_fail2.cpp b/src/boost/libs/tti/test/test_has_static_mem_data_fail2.cpp new file mode 100644 index 00000000..826f5fea --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_data_fail2.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_data.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong enclosing type for DSMember + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(DSMember)<AnotherType,short>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_data_fail3.cpp b/src/boost/libs/tti/test/test_has_static_mem_data_fail3.cpp new file mode 100644 index 00000000..61728fc9 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_data_fail3.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_data.hpp" + +int main() + { + + // Data signature has type which does not exist + + BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(DSMember)<NoType,short> aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_fun.cpp b/src/boost/libs/tti/test/test_has_static_mem_fun.cpp new file mode 100644 index 00000000..d9227851 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_fun.cpp @@ -0,0 +1,27 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_fun.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((HaveTheSIntFunction<AType,int,boost::mpl::vector<long,double> >::value)); + BOOST_TEST((!TheTIntFunction<AType,AType,boost::mpl::vector<long,double> >::value)); + BOOST_TEST((TheTIntFunction<AnotherType,AType,boost::mpl::vector<long,double> >::value)); + BOOST_TEST((TheTIntFunction<AnotherType,AType (long,double)>::value)); + BOOST_TEST((BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(TSFunction)<AnotherType,AType::AStructType,boost::mpl::vector<AType::AnIntType,double> >::value)); + BOOST_TEST((!Pickedname<AnotherType,void>::value)); + + // Passing non-class enclosing type will return false + + BOOST_TEST((!TheTIntFunction<AnotherType &,AType,boost::mpl::vector<long,double> >::value)); + BOOST_TEST((!BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(TSFunction)<unsigned,AType::AStructType,boost::mpl::vector<AType::AnIntType,double> >::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_fun.hpp b/src/boost/libs/tti/test/test_has_static_mem_fun.hpp new file mode 100644 index 00000000..4617f57e --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_fun.hpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_HAS_STATIC_MEMBER_FUNCTION_HPP) +#define TEST_HAS_STATIC_MEMBER_FUNCTION_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_static_member_function.hpp> + +BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION(HaveTheSIntFunction,SIntFunction) +BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION(TheTIntFunction,TIntFunction) +BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(TSFunction) +BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION(Pickedname,SomeStaticFunction) + +#endif // TEST_HAS_STATIC_MEMBER_FUNCTION_HPP diff --git a/src/boost/libs/tti/test/test_has_static_mem_fun_compile.cpp b/src/boost/libs/tti/test/test_has_static_mem_fun_compile.cpp new file mode 100644 index 00000000..9636d848 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_fun_compile.cpp @@ -0,0 +1,26 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + TheTIntFunction<AType,void,boost::mpl::vector<long,double> > aVar; + Pickedname<AnotherType,AType,boost::mpl::vector<long,long> > aVar3; + + // Compile time asserts + + BOOST_MPL_ASSERT((HaveTheSIntFunction<AType,int,boost::mpl::vector<long,double> >)); + BOOST_MPL_ASSERT((TheTIntFunction<AnotherType,AType,boost::mpl::vector<long,double> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(TSFunction)<AnotherType,AType::AStructType,boost::mpl::vector<AType::AnIntType,double> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_fun_fail.cpp b/src/boost/libs/tti/test/test_has_static_mem_fun_fail.cpp new file mode 100644 index 00000000..6f522a20 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_fun_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong function signature for SIntFunction + + BOOST_MPL_ASSERT((HaveTheSIntFunction<AType,int,boost::mpl::vector<float,double> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_mem_fun_fail2.cpp b/src/boost/libs/tti/test/test_has_static_mem_fun_fail2.cpp new file mode 100644 index 00000000..5fbe0430 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_mem_fun_fail2.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_fun.hpp" + +int main() + { + + // Function signature has type which does not exist + + BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(TSFunction)<AnotherType,AType::AClassType,boost::mpl::vector<AType::AnIntType,double> > aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_member.cpp b/src/boost/libs/tti/test/test_has_static_member.cpp new file mode 100644 index 00000000..2a9f7763 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_member.cpp @@ -0,0 +1,26 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_fun.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((HaveTheSIntFunction<AType,int (long,double)>::value)); + BOOST_TEST((!TheTIntFunction<AType,AType (long,double)>::value)); + BOOST_TEST((TheTIntFunction<AnotherType,AType (long,double)>::value)); + BOOST_TEST((BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(TSFunction)<AnotherType,AType::AStructType (AType::AnIntType,double)>::value)); + BOOST_TEST((!Pickedname<AnotherType,void ()>::value)); + + // Passing non-class enclosing type will return false + + BOOST_TEST((!TheTIntFunction<int,AType (long,double)>::value)); + BOOST_TEST((!BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(TSFunction)<AnotherType &,AType::AStructType (AType::AnIntType,double)>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_static_member_compile.cpp b/src/boost/libs/tti/test/test_has_static_member_compile.cpp new file mode 100644 index 00000000..f9c1bb42 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_member_compile.cpp @@ -0,0 +1,26 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + TheTIntFunction<AType,void (long,double)> aVar; + Pickedname<AnotherType,AType (long,long)> aVar3; + + // Compile time asserts + + BOOST_MPL_ASSERT((HaveTheSIntFunction<AType,int (long,double)>)); + BOOST_MPL_ASSERT((TheTIntFunction<AnotherType,AType (long,double)>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(TSFunction)<AnotherType,AType::AStructType (AType::AnIntType,double)>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_member_fail.cpp b/src/boost/libs/tti/test/test_has_static_member_fail.cpp new file mode 100644 index 00000000..cf65d696 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_member_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_fun.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong function signature for SIntFunction + + BOOST_MPL_ASSERT((HaveTheSIntFunction<AType,int (float,double)>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_static_member_fail2.cpp b/src/boost/libs/tti/test/test_has_static_member_fail2.cpp new file mode 100644 index 00000000..5fcbaab0 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_static_member_fail2.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_static_mem_fun.hpp" + +int main() + { + + // Function signature has type which does not exist + + BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(TSFunction)<AnotherType,AType::AClassType (AType::AnIntType,double)> aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template.cpp b/src/boost/libs/tti/test/test_has_template.cpp new file mode 100644 index 00000000..d6ca303f --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template.cpp @@ -0,0 +1,28 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(ATPMemberTemplate)<AType>::value); + BOOST_TEST(HaveCL<AType>::value); + BOOST_TEST(!BOOST_TTI_HAS_TEMPLATE_GEN(AMemberTemplate)<AType>::value); + BOOST_TEST(!HaveAnotherMT<AType>::value); + BOOST_TEST(!BOOST_TTI_HAS_TEMPLATE_GEN(SomeMemberTemplate)<AnotherType>::value); + BOOST_TEST(!ATemplateWithParms<AnotherType>::value); + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(SimpleTMP)<AnotherType>::value); + + // Passing non-class enclosing type will return false + + BOOST_TEST(!HaveCL<AType **>::value); + BOOST_TEST(!BOOST_TTI_HAS_TEMPLATE_GEN(SimpleTMP)<char>::value); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_template.hpp b/src/boost/libs/tti/test/test_has_template.hpp new file mode 100644 index 00000000..cfd61891 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template.hpp @@ -0,0 +1,37 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_HAS_TEMPLATE_HPP) +#define TEST_HAS_TEMPLATE_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_template.hpp> + +#if BOOST_PP_VARIADICS + +BOOST_TTI_HAS_TEMPLATE(ATPMemberTemplate) +BOOST_TTI_TRAIT_HAS_TEMPLATE(HaveCL,CLMemberTemplate,BOOST_PP_NIL) +BOOST_TTI_HAS_TEMPLATE(AMemberTemplate) +BOOST_TTI_TRAIT_HAS_TEMPLATE(HaveAnotherMT,AnotherMemberTemplate,BOOST_PP_NIL) +BOOST_TTI_HAS_TEMPLATE(SomeMemberTemplate,BOOST_PP_NIL) +BOOST_TTI_TRAIT_HAS_TEMPLATE(ATemplateWithParms,ManyParameters) +BOOST_TTI_HAS_TEMPLATE(SimpleTMP,BOOST_PP_NIL) +BOOST_TTI_HAS_TEMPLATE(TemplateNotExist) + +#else // !BOOST_PP_VARIADICS + +BOOST_TTI_HAS_TEMPLATE(ATPMemberTemplate,BOOST_PP_NIL) +BOOST_TTI_TRAIT_HAS_TEMPLATE(HaveCL,CLMemberTemplate,BOOST_PP_NIL) +BOOST_TTI_HAS_TEMPLATE(AMemberTemplate,BOOST_PP_NIL) +BOOST_TTI_TRAIT_HAS_TEMPLATE(HaveAnotherMT,AnotherMemberTemplate,BOOST_PP_NIL) +BOOST_TTI_HAS_TEMPLATE(SomeMemberTemplate,BOOST_PP_NIL) +BOOST_TTI_TRAIT_HAS_TEMPLATE(ATemplateWithParms,ManyParameters,BOOST_PP_NIL) +BOOST_TTI_HAS_TEMPLATE(SimpleTMP,BOOST_PP_NIL) +BOOST_TTI_HAS_TEMPLATE(TemplateNotExist,BOOST_PP_NIL) + +#endif // BOOST_PP_VARIADICS + +#endif // TEST_HAS_TEMPLATE_HPP diff --git a/src/boost/libs/tti/test/test_has_template_compile.cpp b/src/boost/libs/tti/test/test_has_template_compile.cpp new file mode 100644 index 00000000..f789036c --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_compile.cpp @@ -0,0 +1,28 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_TEMPLATE_GEN(AMemberTemplate)<AnotherType> aVar; + HaveAnotherMT<AnotherType> aVar2; + BOOST_TTI_HAS_TEMPLATE_GEN(SomeMemberTemplate)<AType> aVar3; + BOOST_TTI_HAS_TEMPLATE_GEN(TemplateNotExist)<AType> aVar4; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(ATPMemberTemplate)<AType>)); + BOOST_MPL_ASSERT((HaveCL<AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(SimpleTMP)<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_cp.cpp b/src/boost/libs/tti/test/test_has_template_cp.cpp new file mode 100644 index 00000000..b155de7d --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_cp.cpp @@ -0,0 +1,30 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template_cp.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(ATPMemberTemplate)<AType>::value); + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(AMemberTemplate)<AType>::value); + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(SomeMemberTemplate)<AnotherType>::value); + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(SimpleTMP)<AnotherType>::value); + BOOST_TEST(!BOOST_TTI_HAS_TEMPLATE_GEN(TemplateNotExist)<AnotherType>::value); + + BOOST_TEST(HaveCL<AType>::value); + BOOST_TEST(HaveAnotherMT<AType>::value); + BOOST_TEST(ATemplateWithParms<AnotherType>::value); + + // Passing non-class enclosing type will return false + + BOOST_TEST(!BOOST_TTI_HAS_TEMPLATE_GEN(AMemberTemplate)<unsigned char>::value); + BOOST_TEST(!HaveAnotherMT<AType *>::value); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_template_cp.hpp b/src/boost/libs/tti/test/test_has_template_cp.hpp new file mode 100644 index 00000000..001f7463 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_cp.hpp @@ -0,0 +1,24 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_HAS_TEMPLATE_CHECK_PARAMS_HPP) +#define TEST_HAS_TEMPLATE_CHECK_PARAMS_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_template.hpp> + +BOOST_TTI_HAS_TEMPLATE(ATPMemberTemplate,(1,(class))) +BOOST_TTI_TRAIT_HAS_TEMPLATE(HaveCL,CLMemberTemplate,(2,(class,class))) +BOOST_TTI_HAS_TEMPLATE(AMemberTemplate,(1,(int))) +BOOST_TTI_TRAIT_HAS_TEMPLATE(HaveAnotherMT,AnotherMemberTemplate,(2,(int,int))) +BOOST_TTI_HAS_TEMPLATE(SomeMemberTemplate,(6,(class,class,class,class,class,class))) +BOOST_TTI_TRAIT_HAS_TEMPLATE(ATemplateWithParms,ManyParameters,(7,(class,class,int,class,template <class> class,class,long))) +BOOST_TTI_HAS_TEMPLATE(SimpleTMP,(4,(class,class,class,class))) +BOOST_TTI_HAS_TEMPLATE(TemplateNotExist,(3,(int,class,template <class> class ATemplate))) +BOOST_TTI_TRAIT_HAS_TEMPLATE(WrongParametersForMP,ManyParameters,(8,(class,class,int,class,template <class,class> class,class,long))) +BOOST_TTI_TRAIT_HAS_TEMPLATE(WrongParameters2ForMP,ManyParameters,(7,(class,long,int,class,template <class> class,class,long))) + +#endif // TEST_HAS_TEMPLATE_CHECK_PARAMS_HPP diff --git a/src/boost/libs/tti/test/test_has_template_cp_compile.cpp b/src/boost/libs/tti/test/test_has_template_cp_compile.cpp new file mode 100644 index 00000000..0eaa9e0f --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_cp_compile.cpp @@ -0,0 +1,30 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_TEMPLATE_GEN(TemplateNotExist)<AnotherType> aVar1; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(ATPMemberTemplate)<AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(AMemberTemplate)<AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(SomeMemberTemplate)<AnotherType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(SimpleTMP)<AnotherType>)); + + BOOST_MPL_ASSERT((HaveCL<AType>)); + BOOST_MPL_ASSERT((HaveAnotherMT<AType>)); + BOOST_MPL_ASSERT((ATemplateWithParms<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_cp_fail.cpp b/src/boost/libs/tti/test/test_has_template_cp_fail.cpp new file mode 100644 index 00000000..92428080 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_cp_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // TemplateNotExist does not exist at all + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(TemplateNotExist)<AType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_cp_fail2.cpp b/src/boost/libs/tti/test/test_has_template_cp_fail2.cpp new file mode 100644 index 00000000..a8be1129 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_cp_fail2.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong enclosing type + + BOOST_MPL_ASSERT((HaveCL<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_cp_fail3.cpp b/src/boost/libs/tti/test/test_has_template_cp_fail3.cpp new file mode 100644 index 00000000..f9e4a4bc --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_cp_fail3.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong template parameters + + BOOST_MPL_ASSERT((WrongParametersForMP<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_cp_fail4.cpp b/src/boost/libs/tti/test/test_has_template_cp_fail4.cpp new file mode 100644 index 00000000..72582f8b --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_cp_fail4.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong template parameters + + BOOST_MPL_ASSERT((WrongParameters2ForMP<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_fail.cpp b/src/boost/libs/tti/test/test_has_template_fail.cpp new file mode 100644 index 00000000..0a694b4b --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // TemplateNotExist does not exist at all + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(TemplateNotExist)<AType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_fail2.cpp b/src/boost/libs/tti/test/test_has_template_fail2.cpp new file mode 100644 index 00000000..76f705ff --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_fail2.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong enclosing type + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(ATPMemberTemplate)<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_fail3.cpp b/src/boost/libs/tti/test/test_has_template_fail3.cpp new file mode 100644 index 00000000..173acce2 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_fail3.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Too many 'typename' parameters + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(SomeMemberTemplate)<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_template_fail4.cpp b/src/boost/libs/tti/test/test_has_template_fail4.cpp new file mode 100644 index 00000000..5499ce9c --- /dev/null +++ b/src/boost/libs/tti/test/test_has_template_fail4.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_template.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Not all 'typename' parameters + + BOOST_MPL_ASSERT((HaveAnotherMT<AType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type.cpp b/src/boost/libs/tti/test/test_has_type.cpp new file mode 100644 index 00000000..c09b122d --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type.cpp @@ -0,0 +1,30 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST(BOOST_TTI_HAS_TYPE_GEN(AnIntType)<AType>::value); + BOOST_TEST(BOOST_TTI_HAS_TYPE_GEN(AnIntTypeReference)<AType>::value); + BOOST_TEST(NameStruct<AType>::value); + BOOST_TEST(BOOST_TTI_HAS_TYPE_GEN(BType)<AType>::value); + BOOST_TEST(TheInteger<AType::BType>::value); + BOOST_TEST(BOOST_TTI_HAS_TYPE_GEN(CType)<AType::BType>::value); + BOOST_TEST(BOOST_TTI_HAS_TYPE_GEN(AnotherIntegerType)<AType::BType::CType>::value); + BOOST_TEST(SomethingElse<AnotherType>::value); + BOOST_TEST(!BOOST_TTI_HAS_TYPE_GEN(NoOtherType)<AnotherType>::value); + + // Passing non-class enclosing type will return false + + BOOST_TEST(!BOOST_TTI_HAS_TYPE_GEN(AnIntTypeReference)<signed long>::value); + BOOST_TEST(!NameStruct<AType &>::value); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_type.hpp b/src/boost/libs/tti/test/test_has_type.hpp new file mode 100644 index 00000000..e17b5c99 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type.hpp @@ -0,0 +1,23 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_HAS_TYPE_HPP) +#define TEST_HAS_TYPE_HPP + +#include "test_structs.hpp" +#include <boost/tti/has_type.hpp> + +BOOST_TTI_HAS_TYPE(AnIntType) +BOOST_TTI_TRAIT_HAS_TYPE(NameStruct,AStructType) +BOOST_TTI_HAS_TYPE(AnIntTypeReference) +BOOST_TTI_HAS_TYPE(BType) +BOOST_TTI_TRAIT_HAS_TYPE(TheInteger,AnIntegerType) +BOOST_TTI_HAS_TYPE(CType) +BOOST_TTI_HAS_TYPE(AnotherIntegerType) +BOOST_TTI_TRAIT_HAS_TYPE(SomethingElse,someOtherType) +BOOST_TTI_HAS_TYPE(NoOtherType) + +#endif // TEST_HAS_TYPE_HPP diff --git a/src/boost/libs/tti/test/test_has_type_compile.cpp b/src/boost/libs/tti/test/test_has_type_compile.cpp new file mode 100644 index 00000000..bf6047c0 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_compile.cpp @@ -0,0 +1,31 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_TYPE_GEN(AnIntType)<AnotherType> aVar1; + BOOST_TTI_HAS_TYPE_GEN(NoOtherType)<AType> aVar2; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnIntType)<AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnIntTypeReference)<AType>)); + BOOST_MPL_ASSERT((NameStruct<AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(BType)<AType>)); + BOOST_MPL_ASSERT((TheInteger<AType::BType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(CType)<AType::BType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnotherIntegerType)<AType::BType::CType>)); + BOOST_MPL_ASSERT((SomethingElse<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_ct.cpp b/src/boost/libs/tti/test/test_has_type_ct.cpp new file mode 100644 index 00000000..d724262c --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_ct.cpp @@ -0,0 +1,33 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/detail/lightweight_test.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +using namespace boost::mpl::placeholders; + +int main() + { + + BOOST_TEST((BOOST_TTI_HAS_TYPE_GEN(AnIntType)<AType,boost::is_same<int,_> >::value)); + BOOST_TEST((NameStruct<AType,boost::is_same<AType::AStructType,_> >::value)); + BOOST_TEST((BOOST_TTI_HAS_TYPE_GEN(AnIntTypeReference)<AType,boost::is_same<int &,_> >::value)); + BOOST_TEST((BOOST_TTI_HAS_TYPE_GEN(BType)<AType,boost::is_same<AType::BType,_> >::value)); + BOOST_TEST((TheInteger<AType::BType,boost::is_same<int,_> >::value)); + BOOST_TEST((BOOST_TTI_HAS_TYPE_GEN(CType)<AType::BType,boost::is_same<AType::BType::CType,_> >::value)); + BOOST_TEST((BOOST_TTI_HAS_TYPE_GEN(AnotherIntegerType)<AType::BType::CType,boost::is_same<int,_> >::value)); + BOOST_TEST((SomethingElse<AnotherType,boost::is_same<AType::AnIntType,_> >::value)); + BOOST_TEST((!BOOST_TTI_HAS_TYPE_GEN(NoOtherType)<AnotherType,boost::is_same<double,_> >::value)); + + // Passing non-class enclosing type will return false + + BOOST_TEST((!BOOST_TTI_HAS_TYPE_GEN(AnIntTypeReference)<AType **,boost::is_same<int &,_> >::value)); + BOOST_TEST((!SomethingElse<float,boost::is_same<AType::AnIntType,_> >::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_has_type_ct_compile.cpp b/src/boost/libs/tti/test/test_has_type_ct_compile.cpp new file mode 100644 index 00000000..f82428fe --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_ct_compile.cpp @@ -0,0 +1,34 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/assert.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +using namespace boost::mpl::placeholders; + +int main() + { + + // You can always instantiate without compiler errors + + TheInteger<AType::BType,boost::is_same<short,_> > aVar; + BOOST_TTI_HAS_TYPE_GEN(NoOtherType)<AnotherType,boost::is_same<double,_> > aVar2; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnIntType)<AType,boost::is_same<int,_> >)); + BOOST_MPL_ASSERT((NameStruct<AType,boost::is_same<AType::AStructType,_> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnIntTypeReference)<AType,boost::is_same<int &,_> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(BType)<AType,boost::is_same<AType::BType,_> >)); + BOOST_MPL_ASSERT((TheInteger<AType::BType,boost::is_same<int,_> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(CType)<AType::BType,boost::is_same<AType::BType::CType,_> >)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnotherIntegerType)<AType::BType::CType,boost::is_same<int,_> >)); + BOOST_MPL_ASSERT((SomethingElse<AnotherType,boost::is_same<AType::AnIntType,_> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_ct_fail.cpp b/src/boost/libs/tti/test/test_has_type_ct_fail.cpp new file mode 100644 index 00000000..a71301d1 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_ct_fail.cpp @@ -0,0 +1,22 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/assert.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +using namespace boost::mpl::placeholders; + +int main() + { + + // NoOtherType does not exist at all + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(NoOtherType)<AType,boost::is_same<int,_> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_ct_fail2.cpp b/src/boost/libs/tti/test/test_has_type_ct_fail2.cpp new file mode 100644 index 00000000..a2135c4b --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_ct_fail2.cpp @@ -0,0 +1,22 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/assert.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +using namespace boost::mpl::placeholders; + +int main() + { + + // Wrong enclosing type + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(BType)<AnotherType,boost::is_same<short,_> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_ct_fail3.cpp b/src/boost/libs/tti/test/test_has_type_ct_fail3.cpp new file mode 100644 index 00000000..e50e898a --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_ct_fail3.cpp @@ -0,0 +1,21 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +using namespace boost::mpl::placeholders; + +int main() + { + + // Enclosing type does not exist + + TheInteger<AType::EType,boost::is_same<double,_> > aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_ct_fail4.cpp b/src/boost/libs/tti/test/test_has_type_ct_fail4.cpp new file mode 100644 index 00000000..21328ac2 --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_ct_fail4.cpp @@ -0,0 +1,21 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +using namespace boost::mpl::placeholders; + +int main() + { + + // Typedef type does not exist ( BType is a nested type ) + + BOOST_TTI_HAS_TYPE_GEN(BType)<AType,boost::is_same<BType,_> > aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_ct_fail5.cpp b/src/boost/libs/tti/test/test_has_type_ct_fail5.cpp new file mode 100644 index 00000000..1e4e8e0e --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_ct_fail5.cpp @@ -0,0 +1,22 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/assert.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/type_traits/is_same.hpp> +using namespace boost::mpl::placeholders; + +int main() + { + + // Wrong typedef type + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnotherIntegerType)<AType::BType::CType,boost::is_same<long,_> >)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_fail.cpp b/src/boost/libs/tti/test/test_has_type_fail.cpp new file mode 100644 index 00000000..152005cf --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_fail.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // NoOtherType does not exist at all + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(NoOtherType)<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_fail2.cpp b/src/boost/libs/tti/test/test_has_type_fail2.cpp new file mode 100644 index 00000000..8fd9f9fe --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_fail2.cpp @@ -0,0 +1,19 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + // Wrong enclosing type + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(BType)<AnotherType>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_has_type_fail3.cpp b/src/boost/libs/tti/test/test_has_type_fail3.cpp new file mode 100644 index 00000000..cb2ef9df --- /dev/null +++ b/src/boost/libs/tti/test/test_has_type_fail3.cpp @@ -0,0 +1,18 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_has_type.hpp" + +int main() + { + + // Enclosing type does not exist + + TheInteger<AType::EType> aVar; + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_mem_type.cpp b/src/boost/libs/tti/test/test_mem_type.cpp new file mode 100644 index 00000000..72f1dfc4 --- /dev/null +++ b/src/boost/libs/tti/test/test_mem_type.cpp @@ -0,0 +1,34 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_mem_type.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + + BOOST_TEST((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(AnIntType)<AType>::type>::value)); + BOOST_TEST((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(AnIntTypeReference)<AType>::type>::value)); + BOOST_TEST((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(BType)<AType>::type>::value)); + BOOST_TEST((boost::tti::valid_member_type<TheInteger<AType::BType>::type>::value)); + BOOST_TEST((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(AnotherIntegerType)<AType::BType::CType>::type>::value)); + BOOST_TEST((boost::tti::valid_member_type<SomethingElse<AnotherType>::type>::value)); + + BOOST_TEST((boost::tti::valid_member_type<NameStruct<AType,MarkerType>::type,NameStruct<AType,MarkerType>::boost_tti_marker_type>::value)); + BOOST_TEST((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(CType)<AType::BType,MarkerType>::type,BOOST_TTI_MEMBER_TYPE_GEN(CType)<AType::BType,MarkerType>::boost_tti_marker_type>::value)); + + BOOST_TEST((!boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(BType)<AnotherType>::type>::value)); + BOOST_TEST((!boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(NoExistType)<AType,MarkerType>::type,BOOST_TTI_MEMBER_TYPE_GEN(NoExistType)<AType,MarkerType>::boost_tti_marker_type>::value)); + + // Passing non-class enclosing type will always use the marker type + + BOOST_TEST((!boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(BType)<int>::type>::value)); + BOOST_TEST((!boost::tti::valid_member_type<TheInteger<AType::BType *>::type>::value)); + BOOST_TEST((!boost::tti::valid_member_type<NameStruct<long,MarkerType>::type,MarkerType>::value)); + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_mem_type.hpp b/src/boost/libs/tti/test/test_mem_type.hpp new file mode 100644 index 00000000..a1bd6d29 --- /dev/null +++ b/src/boost/libs/tti/test/test_mem_type.hpp @@ -0,0 +1,24 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_MEMBER_TYPE_HPP) +#define TEST_MEMBER_TYPE_HPP + +#include "test_structs.hpp" +#include <boost/tti/member_type.hpp> + +BOOST_TTI_MEMBER_TYPE(AnIntType) +BOOST_TTI_TRAIT_MEMBER_TYPE(NameStruct,AStructType) +BOOST_TTI_MEMBER_TYPE(AnIntTypeReference) +BOOST_TTI_MEMBER_TYPE(BType) +BOOST_TTI_TRAIT_MEMBER_TYPE(TheInteger,AnIntegerType) +BOOST_TTI_MEMBER_TYPE(CType) +BOOST_TTI_MEMBER_TYPE(AnotherIntegerType) +BOOST_TTI_TRAIT_MEMBER_TYPE(SomethingElse,someOtherType) + +BOOST_TTI_MEMBER_TYPE(NoExistType) + +#endif // TEST_MEMBER_TYPE_HPP diff --git a/src/boost/libs/tti/test/test_mem_type_compile.cpp b/src/boost/libs/tti/test/test_mem_type_compile.cpp new file mode 100644 index 00000000..ff59bbf1 --- /dev/null +++ b/src/boost/libs/tti/test/test_mem_type_compile.cpp @@ -0,0 +1,28 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_mem_type.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + + BOOST_MPL_ASSERT((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(AnIntType)<AType>::type>)); + BOOST_MPL_ASSERT((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(AnIntTypeReference)<AType>::type>)); + BOOST_MPL_ASSERT((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(BType)<AType>::type>)); + BOOST_MPL_ASSERT((boost::tti::valid_member_type<TheInteger<AType::BType>::type>)); + BOOST_MPL_ASSERT((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(AnotherIntegerType)<AType::BType::CType>::type>)); + BOOST_MPL_ASSERT((boost::tti::valid_member_type<SomethingElse<AnotherType>::type>)); + + BOOST_MPL_ASSERT((boost::tti::valid_member_type<NameStruct<AType,MarkerType>::type,NameStruct<AType,MarkerType>::boost_tti_marker_type>)); + BOOST_MPL_ASSERT((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(CType)<AType::BType,MarkerType>::type,BOOST_TTI_MEMBER_TYPE_GEN(CType)<AType::BType,MarkerType>::boost_tti_marker_type>)); + + BOOST_MPL_ASSERT_NOT((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(BType)<AnotherType>::type>)); + BOOST_MPL_ASSERT_NOT((boost::tti::valid_member_type<BOOST_TTI_MEMBER_TYPE_GEN(NoExistType)<AType,MarkerType>::type,BOOST_TTI_MEMBER_TYPE_GEN(NoExistType)<AType,MarkerType>::boost_tti_marker_type>)); + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_structs.hpp b/src/boost/libs/tti/test/test_structs.hpp new file mode 100644 index 00000000..e3d9ac2e --- /dev/null +++ b/src/boost/libs/tti/test/test_structs.hpp @@ -0,0 +1,156 @@ + +// (C) Copyright Edward Diener 2011,2012 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_STRUCTS_HPP) +#define TEST_STRUCTS_HPP + +struct AType + { + + // Type + + typedef int AnIntType; + struct AStructType + { + template <class> struct MStrMemberTemplate { }; + template<class X,class Y,short AA> static int StatFuncTemplate(X *,Y) { int ret(AA); return ret; } + }; + typedef int & AnIntTypeReference; + struct BType + { + typedef int AnIntegerType; + struct CType + { + typedef int AnotherIntegerType; + template <class,class,int,short,class,template <class,int> class,class> struct CTManyParameters { }; + template<class X,class Y,class Z,short AA> double SomeFuncTemplate(X,Y *,Z &) { double ret(AA); return ret; } + }; + }; + + // Template + + template <class> struct ATPMemberTemplate { }; + template <int> struct AMemberTemplate { }; + template <int,int> struct AnotherMemberTemplate { }; + template <class,class> struct CLMemberTemplate { }; + + // Data + + int AnInt; + BType IntBT; + BType::CType NestedCT; + + // Function + + void VoidFunction() { } + int IntFunction() { return 0; } + + // Const function + + double AConstFunction(long, char) const { return 2.57; } + void WFunction(float, double = 4.3) const { } + + // Volatile function + + double AVolatileFunction(long, char = 'c') volatile { return 2.58; } + void VolFunction(float, double) volatile { } + + // Const Volatile function + + double ACVFunction(long, char) const volatile { return 2.59; } + void ConstVolFunction(float, double) const volatile { } + + // Function Templates + + template<class X,int Y> int AFuncTemplate(const X &) { return Y; } + template<class X,class Y,class Z> void AFuncTemplate(X *,Y,Z &) { } + + // Static Data + + static short DSMember; + + // Static Function + + static int SIntFunction(long,double) { return 2; } + + // Static Function Template + + template<class X,class Y,class Z> static void AnotherFuncTemplate(X,Y &,const Z &) { } + + }; + +struct AnotherType + { + + // Type + + typedef AType::AnIntType someOtherType; + + // Template + + template <class,class,class,class,class,class> struct SomeMemberTemplate { }; + template <class,class,int,class,template <class> class,class,long> struct ManyParameters { }; + template <class,class,class,class> struct SimpleTMP { }; + + // Data + + bool aMember; + bool cMem; + long AnInt; + AType OtherAT; + AType::AStructType ONestStr; + + // Function + + AType aFunction(int = 7) { return AType(); } + int anotherFunction(AType) { return 0; } + AType::AnIntType sFunction(int,long = 88,double = 1.0) { return 0; } + double IntFunction(int = 9922) { return 0; } + + // Const function + + int AnotherConstFunction(AType *, short) const { return 0; } + AType StillSame(int) const { return OtherAT; } + + // Volatile function + + int AnotherVolatileFunction(AType *, short) volatile { return 0; } + bool StillVolatile(int) volatile { return false; } + + // Const Volatile function + + int AnotherConstVolatileFunction(AType *, short) const volatile { return 0; } + short StillCV(int = 3) const volatile { return 32; } + + // Function Templates + + template<class X> long MyFuncTemplate(X &) { return 0; } + + // Static Function + + static AType TIntFunction(long,double = 3.0) { return AType(); } + static AType::AStructType TSFunction(AType::AnIntType,double) { return AType::AStructType(); } + + // Static Data + + static AType::AStructType AnStat; + + // Static Function Template + + template<class X,class Y> static void YetAnotherFuncTemplate(const X &,Y &) { } + + static const int CIntValue = 10; + + }; + +struct MarkerType + { + }; + +short AType::DSMember(5622); +AType::AStructType AnotherType::AnStat; + +#endif // TEST_STRUCTS_HPP diff --git a/src/boost/libs/tti/test/test_vm_has_template_cp.cpp b/src/boost/libs/tti/test/test_vm_has_template_cp.cpp new file mode 100644 index 00000000..ccd4f583 --- /dev/null +++ b/src/boost/libs/tti/test/test_vm_has_template_cp.cpp @@ -0,0 +1,34 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_vm_has_template_cp.hpp" +#include <boost/detail/lightweight_test.hpp> + +int main() + { + +#if BOOST_PP_VARIADICS + + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(ATPMemberTemplate)<AType>::value); + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(AMemberTemplate)<AType>::value); + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(SomeMemberTemplate)<AnotherType>::value); + BOOST_TEST(BOOST_TTI_HAS_TEMPLATE_GEN(SimpleTMP)<AnotherType>::value); + BOOST_TEST(!BOOST_TTI_HAS_TEMPLATE_GEN(TemplateNotExist)<AnotherType>::value); + + BOOST_TEST(HaveCL<AType>::value); + BOOST_TEST(HaveAnotherMT<AType>::value); + BOOST_TEST(ATemplateWithParms<AnotherType>::value); + + // Passing non-class enclosing type will return false + + BOOST_TEST(!BOOST_TTI_HAS_TEMPLATE_GEN(AMemberTemplate)<AType *>::value); + BOOST_TEST(!ATemplateWithParms<double>::value); + +#endif // BOOST_PP_VARIADICS + + return boost::report_errors(); + + } diff --git a/src/boost/libs/tti/test/test_vm_has_template_cp.hpp b/src/boost/libs/tti/test/test_vm_has_template_cp.hpp new file mode 100644 index 00000000..b9ae3c1d --- /dev/null +++ b/src/boost/libs/tti/test/test_vm_has_template_cp.hpp @@ -0,0 +1,30 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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). + +#if !defined(TEST_VM_HAS_TEMPLATE_CHECK_PARAMS_HPP) +#define TEST_VM_HAS_TEMPLATE_CHECK_PARAMS_HPP + +#include <boost/preprocessor/config/config.hpp> + +#if BOOST_PP_VARIADICS + +#include "test_structs.hpp" +#include <boost/tti/has_template.hpp> + +BOOST_TTI_HAS_TEMPLATE(ATPMemberTemplate,class) +BOOST_TTI_TRAIT_HAS_TEMPLATE(HaveCL,CLMemberTemplate,class,class) +BOOST_TTI_HAS_TEMPLATE(AMemberTemplate,int) +BOOST_TTI_TRAIT_HAS_TEMPLATE(HaveAnotherMT,AnotherMemberTemplate,int,int) +BOOST_TTI_HAS_TEMPLATE(SomeMemberTemplate,class,class,class,class,class,class) +BOOST_TTI_TRAIT_HAS_TEMPLATE(ATemplateWithParms,ManyParameters,class,class,int,class,template <class> class,class,long) +BOOST_TTI_HAS_TEMPLATE(SimpleTMP,class,class,class,class) +BOOST_TTI_HAS_TEMPLATE(TemplateNotExist,int,class,template <class> class ATemplate) +BOOST_TTI_TRAIT_HAS_TEMPLATE(WrongParametersForMP,ManyParameters,class,class,int,class,template <class,class> class,class,long) +BOOST_TTI_TRAIT_HAS_TEMPLATE(WrongParameters2ForMP,ManyParameters,class,long,int,class,template <class> class,class,long) + +#endif // BOOST_PP_VARIADICS + +#endif // TEST_VM_HAS_TEMPLATE_CHECK_PARAMS_HPP diff --git a/src/boost/libs/tti/test/test_vm_has_template_cp_compile.cpp b/src/boost/libs/tti/test/test_vm_has_template_cp_compile.cpp new file mode 100644 index 00000000..4d1059a0 --- /dev/null +++ b/src/boost/libs/tti/test/test_vm_has_template_cp_compile.cpp @@ -0,0 +1,34 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_vm_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + +#if BOOST_PP_VARIADICS + + // You can always instantiate without compiler errors + + BOOST_TTI_HAS_TEMPLATE_GEN(TemplateNotExist)<AnotherType> aVar1; + + // Compile time asserts + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(ATPMemberTemplate)<AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(AMemberTemplate)<AType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(SomeMemberTemplate)<AnotherType>)); + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(SimpleTMP)<AnotherType>)); + + BOOST_MPL_ASSERT((HaveCL<AType>)); + BOOST_MPL_ASSERT((HaveAnotherMT<AType>)); + BOOST_MPL_ASSERT((ATemplateWithParms<AnotherType>)); + +#endif // BOOST_PP_VARIADICS + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_vm_has_template_cp_fail.cpp b/src/boost/libs/tti/test/test_vm_has_template_cp_fail.cpp new file mode 100644 index 00000000..4a6caf6a --- /dev/null +++ b/src/boost/libs/tti/test/test_vm_has_template_cp_fail.cpp @@ -0,0 +1,27 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_vm_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + +#if BOOST_PP_VARIADICS + + // TemplateNotExist does not exist at all + + BOOST_MPL_ASSERT((BOOST_TTI_HAS_TEMPLATE_GEN(TemplateNotExist)<AType>)); + +#else + + BOOST_MPL_ASSERT((boost::mpl::false_)); + +#endif // BOOST_PP_VARIADICS + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_vm_has_template_cp_fail2.cpp b/src/boost/libs/tti/test/test_vm_has_template_cp_fail2.cpp new file mode 100644 index 00000000..6d4da5a1 --- /dev/null +++ b/src/boost/libs/tti/test/test_vm_has_template_cp_fail2.cpp @@ -0,0 +1,27 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_vm_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + +#if BOOST_PP_VARIADICS + + // Wrong enclosing type + + BOOST_MPL_ASSERT((HaveCL<AnotherType>)); + +#else + + BOOST_MPL_ASSERT((boost::mpl::false_)); + +#endif // BOOST_PP_VARIADICS + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_vm_has_template_cp_fail3.cpp b/src/boost/libs/tti/test/test_vm_has_template_cp_fail3.cpp new file mode 100644 index 00000000..4bcba594 --- /dev/null +++ b/src/boost/libs/tti/test/test_vm_has_template_cp_fail3.cpp @@ -0,0 +1,27 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_vm_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + +#if BOOST_PP_VARIADICS + + // Wrong template parameters + + BOOST_MPL_ASSERT((WrongParametersForMP<AnotherType>)); + +#else + + BOOST_MPL_ASSERT((boost::mpl::false_)); + +#endif // BOOST_PP_VARIADICS + + return 0; + + } diff --git a/src/boost/libs/tti/test/test_vm_has_template_cp_fail4.cpp b/src/boost/libs/tti/test/test_vm_has_template_cp_fail4.cpp new file mode 100644 index 00000000..46e3997c --- /dev/null +++ b/src/boost/libs/tti/test/test_vm_has_template_cp_fail4.cpp @@ -0,0 +1,27 @@ + +// (C) Copyright Edward Diener 2011 +// Use, modification and distribution are subject to 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 "test_vm_has_template_cp.hpp" +#include <boost/mpl/assert.hpp> + +int main() + { + +#if BOOST_PP_VARIADICS + + // Wrong template parameters + + BOOST_MPL_ASSERT((WrongParameters2ForMP<AnotherType>)); + +#else + + BOOST_MPL_ASSERT((boost::mpl::false_)); + +#endif // BOOST_PP_VARIADICS + + return 0; + + } |