diff --git a/call_traits_test.cpp b/call_traits_test.cpp index d0db895..ee4e048 100644 --- a/call_traits_test.cpp +++ b/call_traits_test.cpp @@ -1,3 +1,10 @@ + // boost::compressed_pair test program + + // (C) Copyright John Maddock 2000. Permission to copy, use, modify, sell and + // distribute this software is granted provided this copyright notice appears + // in all copies. This software is provided "as is" without express or implied + // warranty, and with no claim as to its suitability for any purpose. + #include #include @@ -6,12 +13,7 @@ #include #include -#ifdef __BORLANDC__ -// turn off some warnings, the way we do the tests will generate a *lot* of these -// this is a result of the tests not call_traits itself.... -#pragma option -w-8004 -w-ccc -w-rch -w-eff -w-aus -#endif - +#include "type_traits_test.hpp" // // struct contained models a type that contains a type (for example std::pair) // arrays are contained by value, and have to be treated as a special case: @@ -178,30 +180,6 @@ struct UDT bool operator == (const UDT& v){ return v.i_ == i_; } }; -// -// define tests here -unsigned failures = 0; -unsigned test_count = 0; - -#define value_test(v, x) ++test_count;\ - if(v != x){++failures; std::cout << "checking value of " << #x << "...failed" << std::endl;} - -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -#define type_test(v, x) ++test_count;\ - if(boost::is_same::value == false){\ - ++failures; \ - std::cout << "checking type of " << #x << "...failed" << std::endl; \ - std::cout << " expected type was " << #v << std::endl; \ - std::cout << " " << typeid(boost::is_same).name() << "::value is false" << std::endl; } -#else -#define type_test(v, x) ++test_count;\ - if(typeid(v) != typeid(x)){\ - ++failures; \ - std::cout << "checking type of " << #x << "...failed" << std::endl; \ - std::cout << " expected type was " << #v << std::endl; \ - std::cout << " " << "typeid(" #v ") != typeid(" #x ")" << std::endl; } -#endif - int main() { checker c1; diff --git a/compressed_pair_test.cpp b/compressed_pair_test.cpp index c34aa17..a91d4b8 100644 --- a/compressed_pair_test.cpp +++ b/compressed_pair_test.cpp @@ -10,38 +10,10 @@ #include #include +#include "type_traits_test.hpp" using namespace boost; -#ifdef __BORLANDC__ -#pragma option -w-ccc -w-rch -w-eff -w-aus -#endif - -// -// define tests here -unsigned failures = 0; -unsigned test_count = 0; - -#define value_test(v, x) ++test_count;\ - if(v != x){++failures; std::cout << "checking value of " << #x << "...failed" << std::endl;} -#define value_fail(v, x) ++test_count; ++failures; std::cout << "checking value of " << #x << "...failed" << std::endl; - -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -#define type_test(v, x) ++test_count;\ - if(boost::is_same::value == false){\ - ++failures; \ - std::cout << "checking type of " << #x << "...failed" << std::endl; \ - std::cout << " expected type was " << #v << std::endl; \ - std::cout << " " << typeid(boost::is_same).name() << "::value is false" << std::endl; } -#else -#define type_test(v, x) ++test_count;\ - if(typeid(v) != typeid(x)){\ - ++failures; \ - std::cout << "checking type of " << #x << "...failed" << std::endl; \ - std::cout << " expected type was " << #v << std::endl; \ - std::cout << " " << "typeid(" #v ") != typeid(" #x ")" << std::endl; } -#endif - struct empty_POD_UDT{}; struct empty_UDT { diff --git a/type_traits_test.cpp b/type_traits_test.cpp index 8c0e460..b763bfe 100644 --- a/type_traits_test.cpp +++ b/type_traits_test.cpp @@ -16,37 +16,10 @@ #include #include +#include "type_traits_test.hpp" using namespace boost; -#ifdef __BORLANDC__ -#pragma option -w-ccc -w-rch -w-eff -w-aus -#endif - -// -// define tests here -unsigned failures = 0; -unsigned test_count = 0; - -#define value_test(v, x) ++test_count;\ - if(v != x){++failures; std::cout << "checking value of " << #x << "...failed" << std::endl;} -#define value_fail(v, x) ++test_count; ++failures; std::cout << "checking value of " << #x << "...failed" << std::endl; -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -#define type_test(v, x) ++test_count;\ - if(is_same::value == false){\ - ++failures; \ - std::cout << "checking type of " << #x << "...failed" << std::endl; \ - std::cout << " expected type was " << #v << std::endl; \ - std::cout << " " << typeid(is_same).name() << "::value is false" << std::endl; } -#else -#define type_test(v, x) ++test_count;\ - if(typeid(v) != typeid(x)){\ - ++failures; \ - std::cout << "checking type of " << #x << "...failed" << std::endl; \ - std::cout << " expected type was " << #v << std::endl; \ - std::cout << " " << "typeid(" #v ") != typeid(" #x ")" << std::endl; } -#endif - // Since there is no compiler support, we should specialize: // is_enum for all enumerations (is_enum implies is_POD) // is_union for all unions @@ -160,6 +133,33 @@ template <> struct is_POD } #endif +class Base { }; + +class Deriverd : public Base { }; + +class NonDerived { }; + +enum enum1 +{ + one_,two_ +}; + +enum enum2 +{ + three_,four_ +}; + +struct VB +{ + virtual ~VB(){}; +}; + +struct VD : VB +{ + ~VD(){}; +}; + + // Steve: All comments that I (Steve Cleary) have added below are prefixed with // "Steve:" The failures that BCB4 has on the tests are due to Borland's // not considering cv-qual's as a part of the type -- they are considered @@ -530,6 +530,52 @@ int main() value_test(false, is_POD::value) value_test(true, is_POD::value) + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + //value_test(false, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); +#if defined(BOOST_MSVC6_MEMBER_TEMPLATES) || !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + value_test(false, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); +#endif + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + + value_test(false, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(true, (boost::is_convertible::value)); + value_test(false, (boost::is_convertible::value)); + + align_test(int); + align_test(char); + align_test(double); + align_test(int[4]); + //align_test(int&); + align_test(int*); + //align_test(const int); + align_test(VB); + align_test(VD); + std::cout << std::endl << test_count << " tests completed (" << failures << " failures)... press any key to exit"; std::cin.get(); return failures;