diff --git a/call_traits_test.cpp b/call_traits_test.cpp index 872e08c..628f7b5 100644 --- a/call_traits_test.cpp +++ b/call_traits_test.cpp @@ -20,6 +20,41 @@ #include #include +#include + +// +// define tests here +unsigned failures = 0; +unsigned test_count = 0; +// +// This must get defined within the test file. +// All compilers have bugs, set this to the number of +// regressions *expected* from a given compiler, +// if there are no workarounds for the bugs, *and* +// the regressions have been investigated. +// +extern unsigned int expected_failures; +// +// proc check_result() +// Checks that there were no regressions: +// +int check_result(int argc, char** argv) +{ + std::cout << test_count << " tests completed, " + << failures << " failures found, " + << expected_failures << " failures expected from this compiler." << std::endl; + if((argc == 2) + && (argv[1][0] == '-') + && (argv[1][1] == 'a') + && (argv[1][2] == 0)) + { + std::cout << "Press any key to continue..."; + std::cin.get(); + } + return (failures == expected_failures) + ? 0 + : (failures != 0) ? static_cast(failures) : -1; +} // a way prevent warnings for unused variables template inline void unused_variable(const T&) {} @@ -231,51 +266,51 @@ int main(int argc, char *argv[ ]) typedef int& r_type; typedef const r_type cr_type; - type_test(comparible_UDT, boost::call_traits::value_type) - type_test(comparible_UDT&, boost::call_traits::reference) - type_test(const comparible_UDT&, boost::call_traits::const_reference) - type_test(const comparible_UDT&, boost::call_traits::param_type) - type_test(int, boost::call_traits::value_type) - type_test(int&, boost::call_traits::reference) - type_test(const int&, boost::call_traits::const_reference) - type_test(const int, boost::call_traits::param_type) - type_test(int*, boost::call_traits::value_type) - type_test(int*&, boost::call_traits::reference) - type_test(int*const&, boost::call_traits::const_reference) - type_test(int*const, boost::call_traits::param_type) + BOOST_CHECK_TYPE(comparible_UDT, boost::call_traits::value_type); + BOOST_CHECK_TYPE(comparible_UDT&, boost::call_traits::reference); + BOOST_CHECK_TYPE(const comparible_UDT&, boost::call_traits::const_reference); + BOOST_CHECK_TYPE(const comparible_UDT&, boost::call_traits::param_type); + BOOST_CHECK_TYPE(int, boost::call_traits::value_type); + BOOST_CHECK_TYPE(int&, boost::call_traits::reference); + BOOST_CHECK_TYPE(const int&, boost::call_traits::const_reference); + BOOST_CHECK_TYPE(const int, boost::call_traits::param_type); + BOOST_CHECK_TYPE(int*, boost::call_traits::value_type); + BOOST_CHECK_TYPE(int*&, boost::call_traits::reference); + BOOST_CHECK_TYPE(int*const&, boost::call_traits::const_reference); + BOOST_CHECK_TYPE(int*const, boost::call_traits::param_type); #if defined(BOOST_MSVC6_MEMBER_TEMPLATES) - type_test(int&, boost::call_traits::value_type) - type_test(int&, boost::call_traits::reference) - type_test(const int&, boost::call_traits::const_reference) - type_test(int&, boost::call_traits::param_type) + BOOST_CHECK_TYPE(int&, boost::call_traits::value_type); + BOOST_CHECK_TYPE(int&, boost::call_traits::reference); + BOOST_CHECK_TYPE(const int&, boost::call_traits::const_reference); + BOOST_CHECK_TYPE(int&, boost::call_traits::param_type); #if !(defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC__ == 3) && (__GNUC_MINOR__ < 1))) - type_test(int&, boost::call_traits::value_type) - type_test(int&, boost::call_traits::reference) - type_test(const int&, boost::call_traits::const_reference) - type_test(int&, boost::call_traits::param_type) + BOOST_CHECK_TYPE(int&, boost::call_traits::value_type); + BOOST_CHECK_TYPE(int&, boost::call_traits::reference); + BOOST_CHECK_TYPE(const int&, boost::call_traits::const_reference); + BOOST_CHECK_TYPE(int&, boost::call_traits::param_type); #else std::cout << "Your compiler cannot instantiate call_traits, skipping four tests (4 errors)" << std::endl; failures += 4; test_count += 4; #endif - type_test(const int&, boost::call_traits::value_type) - type_test(const int&, boost::call_traits::reference) - type_test(const int&, boost::call_traits::const_reference) - type_test(const int&, boost::call_traits::param_type) + BOOST_CHECK_TYPE(const int&, boost::call_traits::value_type); + BOOST_CHECK_TYPE(const int&, boost::call_traits::reference); + BOOST_CHECK_TYPE(const int&, boost::call_traits::const_reference); + BOOST_CHECK_TYPE(const int&, boost::call_traits::param_type); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - type_test(const int*, boost::call_traits::value_type) - type_test(int(&)[3], boost::call_traits::reference) - type_test(const int(&)[3], boost::call_traits::const_reference) - type_test(const int*const, boost::call_traits::param_type) - type_test(const int*, boost::call_traits::value_type) - type_test(const int(&)[3], boost::call_traits::reference) - type_test(const int(&)[3], boost::call_traits::const_reference) - type_test(const int*const, boost::call_traits::param_type) + BOOST_CHECK_TYPE(const int*, boost::call_traits::value_type); + BOOST_CHECK_TYPE(int(&)[3], boost::call_traits::reference); + BOOST_CHECK_TYPE(const int(&)[3], boost::call_traits::const_reference); + BOOST_CHECK_TYPE(const int*const, boost::call_traits::param_type); + BOOST_CHECK_TYPE(const int*, boost::call_traits::value_type); + BOOST_CHECK_TYPE(const int(&)[3], boost::call_traits::reference); + BOOST_CHECK_TYPE(const int(&)[3], boost::call_traits::const_reference); + BOOST_CHECK_TYPE(const int*const, boost::call_traits::param_type); // test with abstract base class: - type_test(test_abc1, boost::call_traits::value_type) - type_test(test_abc1&, boost::call_traits::reference) - type_test(const test_abc1&, boost::call_traits::const_reference) - type_test(const test_abc1&, boost::call_traits::param_type) + BOOST_CHECK_TYPE(test_abc1, boost::call_traits::value_type); + BOOST_CHECK_TYPE(test_abc1&, boost::call_traits::reference); + BOOST_CHECK_TYPE(const test_abc1&, boost::call_traits::const_reference); + BOOST_CHECK_TYPE(const test_abc1&, boost::call_traits::param_type); #else std::cout << "You're compiler does not support partial template specialiation, skipping 8 tests (8 errors)" << std::endl; failures += 12; @@ -287,10 +322,10 @@ int main(int argc, char *argv[ ]) test_count += 24; #endif // test with an incomplete type: - type_test(incomplete_type, boost::call_traits::value_type) - type_test(incomplete_type&, boost::call_traits::reference) - type_test(const incomplete_type&, boost::call_traits::const_reference) - type_test(const incomplete_type&, boost::call_traits::param_type) + BOOST_CHECK_TYPE(incomplete_type, boost::call_traits::value_type); + BOOST_CHECK_TYPE(incomplete_type&, boost::call_traits::reference); + BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits::const_reference); + BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits::param_type); return check_result(argc, argv); } diff --git a/compressed_pair_test.cpp b/compressed_pair_test.cpp index 026fa59..02878c9 100644 --- a/compressed_pair_test.cpp +++ b/compressed_pair_test.cpp @@ -14,29 +14,23 @@ #include #include -#include -#define BOOST_INCLUDE_MAIN -#include +#include using namespace boost; -namespace boost { -#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION -template <> struct is_empty -{ static const bool value = true; }; -template <> struct is_empty -{ static const bool value = true; }; -template <> struct is_POD -{ static const bool value = true; }; -#else -template <> struct is_empty -{ enum{ value = true }; }; -template <> struct is_empty -{ enum{ value = true }; }; -template <> struct is_POD -{ enum{ value = true }; }; -#endif -} +struct empty_UDT +{ + ~empty_UDT(){}; + empty_UDT& operator=(const empty_UDT&){ return *this; } + bool operator==(const empty_UDT&)const + { return true; } +}; +struct empty_POD_UDT +{ + empty_POD_UDT& operator=(const empty_POD_UDT&){ return *this; } + bool operator==(const empty_POD_UDT&)const + { return true; } +}; struct non_empty1 {