diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 318898a..30062d7 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -66,14 +66,17 @@ alias tti [ compile TestMFHasMemberFunctionCompile.cpp ] [ compile-fail TestMFHasMemberFunctionFail.cpp ] [ compile-fail TestMFHasMemberFunctionFail2.cpp ] + [ compile-fail TestMFHasMemberFunctionFail3.cpp ] [ run TestMFHasStaticData.cpp ] [ compile TestMFHasStaticDataCompile.cpp ] [ compile-fail TestMFHasStaticDataFail.cpp ] [ compile-fail TestMFHasStaticDataFail2.cpp ] + [ compile-fail TestMFHasStaticDataFail3.cpp ] [ run TestMFHasStaticFunction.cpp ] [ compile TestMFHasStaticFunctionCompile.cpp ] [ compile-fail TestMFHasStaticFunctionFail.cpp ] [ compile-fail TestMFHasStaticFunctionFail2.cpp ] + [ compile-fail TestMFHasStaticFunctionFail3.cpp ] [ run TestMFHasType.cpp ] [ compile TestMFHasTypeCompile.cpp ] [ compile-fail TestMFHasTypeFail.cpp ] diff --git a/test/TestMFHasMemberData.cpp b/test/TestMFHasMemberData.cpp index 87149a8..aff6fd3 100644 --- a/test/TestMFHasMemberData.cpp +++ b/test/TestMFHasMemberData.cpp @@ -5,10 +5,41 @@ int main() { - BOOST_TEST((tti::mf_has_member_data,boost::mpl::identity >::value)); - BOOST_TEST((tti::mf_has_member_data,boost::mpl::identity >::value)); - BOOST_TEST((tti::mf_has_member_data,boost::mpl::identity >::value)); - BOOST_TEST((tti::mf_has_member_data,boost::mpl::identity >::value)); + BOOST_TEST((tti::mf_has_member_data + < + tti::has_member_AnInt, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_member_data + < + tti::has_member_AnInt, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_member_data + < + tti::has_member_aMember, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_member_data + < + tti::CMember, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); return boost::report_errors(); diff --git a/test/TestMFHasMemberDataCompile.cpp b/test/TestMFHasMemberDataCompile.cpp index b1ae762..b9df1f6 100644 --- a/test/TestMFHasMemberDataCompile.cpp +++ b/test/TestMFHasMemberDataCompile.cpp @@ -4,10 +4,37 @@ int main() { - BOOST_MPL_ASSERT((tti::mf_has_member_data,boost::mpl::identity >)); - BOOST_MPL_ASSERT((tti::mf_has_member_data,boost::mpl::identity >)); - BOOST_MPL_ASSERT((tti::mf_has_member_data,boost::mpl::identity >)); - BOOST_MPL_ASSERT((tti::mf_has_member_data,boost::mpl::identity >)); + BOOST_MPL_ASSERT((tti::mf_has_member_data + < + tti::has_member_AnInt, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_member_data + < + tti::has_member_AnInt, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_member_data + < + tti::has_member_aMember, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_member_data + < + tti::CMember, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasMemberDataFail.cpp b/test/TestMFHasMemberDataFail.cpp index f6db1d2..9b1a0a1 100644 --- a/test/TestMFHasMemberDataFail.cpp +++ b/test/TestMFHasMemberDataFail.cpp @@ -7,7 +7,13 @@ int main() // someDataMember does not exist at all - BOOST_MPL_ASSERT((tti::mf_has_member_data,boost::mpl::identity >)); + BOOST_MPL_ASSERT((tti::mf_has_member_data + < + tti::has_member_someDataMember, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasMemberDataFail2.cpp b/test/TestMFHasMemberDataFail2.cpp index ceba933..36a778b 100644 --- a/test/TestMFHasMemberDataFail2.cpp +++ b/test/TestMFHasMemberDataFail2.cpp @@ -7,7 +7,13 @@ int main() // Wrong data signature for AnInt - BOOST_MPL_ASSERT((tti::mf_has_member_data,boost::mpl::identity >)); + BOOST_MPL_ASSERT((tti::mf_has_member_data + < + tti::has_member_AnInt, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasMemberDataFail3.cpp b/test/TestMFHasMemberDataFail3.cpp index 0510485..3542c86 100644 --- a/test/TestMFHasMemberDataFail3.cpp +++ b/test/TestMFHasMemberDataFail3.cpp @@ -7,7 +7,13 @@ int main() // Wrong enclosing type - BOOST_MPL_ASSERT((tti::mf_has_member_data,boost::mpl::identity >)); + BOOST_MPL_ASSERT((tti::mf_has_member_data + < + tti::has_member_aMember, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasMemberFunction.cpp b/test/TestMFHasMemberFunction.cpp index d33acb8..be65dff 100644 --- a/test/TestMFHasMemberFunction.cpp +++ b/test/TestMFHasMemberFunction.cpp @@ -4,6 +4,66 @@ int main() { + BOOST_TEST((tti::mf_has_member_function + < + tti::has_member_VoidFunction, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_member_function + < + tti::FunctionReturningInt, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_member_function + < + tti::FunctionReturningInt, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_member_function + < + tti::has_member_aFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_member_function + < + tti::AnotherIntFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_member_function + < + tti::has_member_sFunction, + boost::mpl::identity, + tti::member_type_AnIntType, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + return boost::report_errors(); } diff --git a/test/TestMFHasMemberFunction.hpp b/test/TestMFHasMemberFunction.hpp index c63f822..d3078ed 100644 --- a/test/TestMFHasMemberFunction.hpp +++ b/test/TestMFHasMemberFunction.hpp @@ -4,4 +4,13 @@ #include "TestStructs.hpp" #include +TTI_HAS_MEMBER(VoidFunction) +TTI_TRAIT_HAS_MEMBER(FunctionReturningInt,IntFunction) +TTI_HAS_MEMBER(aFunction) +TTI_TRAIT_HAS_MEMBER(AnotherIntFunction,anotherFunction) +TTI_HAS_MEMBER(sFunction) +TTI_HAS_MEMBER(someFunctionMember) + +TTI_MEMBER_TYPE(AnIntType) + #endif // TEST_MF_HAS_MEMBER_FUNCTION_HPP diff --git a/test/TestMFHasMemberFunctionCompile.cpp b/test/TestMFHasMemberFunctionCompile.cpp index 20ad3df..0236a9c 100644 --- a/test/TestMFHasMemberFunctionCompile.cpp +++ b/test/TestMFHasMemberFunctionCompile.cpp @@ -4,8 +4,91 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::true_)); + // You can always instantiate without compiler errors + tti::mf_has_member_function + < + tti::FunctionReturningInt, + boost::mpl::identity, + boost::mpl::identity + > aVar; + + tti::mf_has_member_function + < + tti::has_member_sFunction, + boost::mpl::identity, + tti::member_type_AnIntType, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > aVar2; + + tti::mf_has_member_function + < + tti::has_member_someFunctionMember, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > aVar3; + + // Compile time asserts + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::has_member_VoidFunction, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::FunctionReturningInt, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::FunctionReturningInt, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::has_member_aFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::AnotherIntFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::has_member_sFunction, + boost::mpl::identity, + tti::member_type_AnIntType, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); + return 0; } diff --git a/test/TestMFHasMemberFunctionFail.cpp b/test/TestMFHasMemberFunctionFail.cpp index 1b8be82..2b09ed1 100644 --- a/test/TestMFHasMemberFunctionFail.cpp +++ b/test/TestMFHasMemberFunctionFail.cpp @@ -4,7 +4,18 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::false_)); + // someFunctionMember does not exist at all + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::has_member_someFunctionMember, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasMemberFunctionFail2.cpp b/test/TestMFHasMemberFunctionFail2.cpp index 1b8be82..0c4dee9 100644 --- a/test/TestMFHasMemberFunctionFail2.cpp +++ b/test/TestMFHasMemberFunctionFail2.cpp @@ -4,7 +4,15 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::false_)); + // Wrong function signature + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::FunctionReturningInt, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasMemberFunctionFail3.cpp b/test/TestMFHasMemberFunctionFail3.cpp new file mode 100644 index 0000000..a378313 --- /dev/null +++ b/test/TestMFHasMemberFunctionFail3.cpp @@ -0,0 +1,22 @@ +#include "TestMFHasMemberFunction.hpp" +#include + +int main() + { + + // Wrong enclosing type for nested type + + BOOST_MPL_ASSERT((tti::mf_has_member_function + < + tti::has_member_sFunction, + boost::mpl::identity, + tti::member_type_AnIntType, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); + + return 0; + + } diff --git a/test/TestMFHasStaticData.cpp b/test/TestMFHasStaticData.cpp index cdf979b..8536ef3 100644 --- a/test/TestMFHasStaticData.cpp +++ b/test/TestMFHasStaticData.cpp @@ -4,6 +4,15 @@ int main() { + BOOST_TEST((tti::mf_has_static_data + < + tti::has_static_member_DSMember, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + return boost::report_errors(); } diff --git a/test/TestMFHasStaticData.hpp b/test/TestMFHasStaticData.hpp index 3998fe1..0921e24 100644 --- a/test/TestMFHasStaticData.hpp +++ b/test/TestMFHasStaticData.hpp @@ -4,4 +4,7 @@ #include "TestStructs.hpp" #include +TTI_HAS_STATIC_MEMBER(DSMember) +TTI_HAS_STATIC_MEMBER(SomeStaticData) + #endif // TEST_MF_HAS_STATIC_DATA_HPP diff --git a/test/TestMFHasStaticDataCompile.cpp b/test/TestMFHasStaticDataCompile.cpp index effd06c..da36553 100644 --- a/test/TestMFHasStaticDataCompile.cpp +++ b/test/TestMFHasStaticDataCompile.cpp @@ -4,7 +4,24 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::true_)); + // You can always instantiate without compiler errors + + tti::mf_has_static_data + < + tti::has_static_member_SomeStaticData, + boost::mpl::identity, + boost::mpl::identity + > aVar; + + // Compile time asserts + + BOOST_MPL_ASSERT((tti::mf_has_static_data + < + tti::has_static_member_DSMember, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasStaticDataFail.cpp b/test/TestMFHasStaticDataFail.cpp index 199caf9..8a31f20 100644 --- a/test/TestMFHasStaticDataFail.cpp +++ b/test/TestMFHasStaticDataFail.cpp @@ -4,7 +4,15 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::false_)); + // SomeStaticData does not exist at all + + BOOST_MPL_ASSERT((tti::mf_has_static_data + < + tti::has_static_member_SomeStaticData, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasStaticDataFail2.cpp b/test/TestMFHasStaticDataFail2.cpp index 199caf9..34b0c90 100644 --- a/test/TestMFHasStaticDataFail2.cpp +++ b/test/TestMFHasStaticDataFail2.cpp @@ -4,7 +4,15 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::false_)); + // Wrong enclosing type + + BOOST_MPL_ASSERT((tti::mf_has_static_data + < + tti::has_static_member_DSMember, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasStaticDataFail3.cpp b/test/TestMFHasStaticDataFail3.cpp new file mode 100644 index 0000000..e29b69a --- /dev/null +++ b/test/TestMFHasStaticDataFail3.cpp @@ -0,0 +1,19 @@ +#include "TestMFHasStaticData.hpp" +#include + +int main() + { + + // Wrong member type + + BOOST_MPL_ASSERT((tti::mf_has_static_data + < + tti::has_static_member_DSMember, + boost::mpl::identity, + boost::mpl::identity + > + )); + + return 0; + + } diff --git a/test/TestMFHasStaticFunction.cpp b/test/TestMFHasStaticFunction.cpp index 29ab786..3896e01 100644 --- a/test/TestMFHasStaticFunction.cpp +++ b/test/TestMFHasStaticFunction.cpp @@ -4,6 +4,39 @@ int main() { + BOOST_TEST((tti::mf_has_static_function + < + tti::HaveTheSIntFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_static_function + < + tti::TheTIntFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + ::value + )); + + BOOST_TEST((tti::mf_has_static_function + < + tti::has_static_member_TSFunction, + boost::mpl::identity, + tti::member_type_AStructType, + tti::NameIntType, + boost::mpl::identity + > + ::value + )); + return boost::report_errors(); } diff --git a/test/TestMFHasStaticFunction.hpp b/test/TestMFHasStaticFunction.hpp index fdaf3fb..3883ed7 100644 --- a/test/TestMFHasStaticFunction.hpp +++ b/test/TestMFHasStaticFunction.hpp @@ -4,4 +4,12 @@ #include "TestStructs.hpp" #include +TTI_TRAIT_HAS_STATIC_MEMBER(HaveTheSIntFunction,SIntFunction) +TTI_TRAIT_HAS_STATIC_MEMBER(TheTIntFunction,TIntFunction) +TTI_HAS_STATIC_MEMBER(TSFunction) +TTI_TRAIT_HAS_STATIC_MEMBER(Pickedname,SomeStaticFunction) + +TTI_MEMBER_TYPE(AStructType) +TTI_TRAIT_MEMBER_TYPE(NameIntType,AnIntType) + #endif // TEST_MF_HAS_STATIC_FUNCTION_HPP diff --git a/test/TestMFHasStaticFunctionCompile.cpp b/test/TestMFHasStaticFunctionCompile.cpp index bb515bf..20d5408 100644 --- a/test/TestMFHasStaticFunctionCompile.cpp +++ b/test/TestMFHasStaticFunctionCompile.cpp @@ -4,7 +4,56 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::true_)); + // You can always instantiate without compiler errors + + tti::mf_has_static_function + < + tti::HaveTheSIntFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > aVar; + + tti::mf_has_static_function + < + tti::Pickedname, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > aVar2; + + // Compile time asserts + + BOOST_MPL_ASSERT((tti::mf_has_static_function + < + tti::HaveTheSIntFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_static_function + < + tti::TheTIntFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); + + BOOST_MPL_ASSERT((tti::mf_has_static_function + < + tti::has_static_member_TSFunction, + boost::mpl::identity, + tti::member_type_AStructType, + tti::NameIntType, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasStaticFunctionFail.cpp b/test/TestMFHasStaticFunctionFail.cpp index 5e0944e..7ae25bc 100644 --- a/test/TestMFHasStaticFunctionFail.cpp +++ b/test/TestMFHasStaticFunctionFail.cpp @@ -4,7 +4,17 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::false_)); + // SomeStaticFunction does not exist at all + + BOOST_MPL_ASSERT((tti::mf_has_static_function + < + tti::Pickedname, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasStaticFunctionFail2.cpp b/test/TestMFHasStaticFunctionFail2.cpp index 5e0944e..7592e70 100644 --- a/test/TestMFHasStaticFunctionFail2.cpp +++ b/test/TestMFHasStaticFunctionFail2.cpp @@ -4,7 +4,17 @@ int main() { - BOOST_MPL_ASSERT((boost::mpl::false_)); + // Wrong enclosing type + + BOOST_MPL_ASSERT((tti::mf_has_static_function + < + tti::HaveTheSIntFunction, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity, + boost::mpl::identity + > + )); return 0; diff --git a/test/TestMFHasStaticFunctionFail3.cpp b/test/TestMFHasStaticFunctionFail3.cpp new file mode 100644 index 0000000..ce4f44d --- /dev/null +++ b/test/TestMFHasStaticFunctionFail3.cpp @@ -0,0 +1,21 @@ +#include "TestMFHasStaticFunction.hpp" +#include + +int main() + { + + // Wrong function parameter type + + BOOST_MPL_ASSERT((tti::mf_has_static_function + < + tti::has_static_member_TSFunction, + boost::mpl::identity, + tti::member_type_AStructType, + tti::NameIntType, + boost::mpl::identity + > + )); + + return 0; + + }