type_traits: regression failure fixes from type traits changes...

[SVN r9249]
This commit is contained in:
John Maddock 2001-02-18 11:43:01 +00:00
parent 20d804afc4
commit 91078b7f7a
6 changed files with 55 additions and 41 deletions

View File

@ -16,7 +16,7 @@
#include <typeinfo> #include <typeinfo>
#include <boost/call_traits.hpp> #include <boost/call_traits.hpp>
#include "type_traits_test.hpp" #include <boost/type_traits/type_traits_test.hpp>
// //
// struct contained models a type that contains a type (for example std::pair) // 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: // arrays are contained by value, and have to be treated as a special case:
@ -98,18 +98,18 @@ std::pair<
using namespace std; using namespace std;
// //
// struct checker: // struct call_traits_checker:
// verifies behaviour of contained example: // verifies behaviour of contained example:
// //
template <class T> template <class T>
struct checker struct call_traits_checker
{ {
typedef typename boost::call_traits<T>::param_type param_type; typedef typename boost::call_traits<T>::param_type param_type;
void operator()(param_type); void operator()(param_type);
}; };
template <class T> template <class T>
void checker<T>::operator()(param_type p) void call_traits_checker<T>::operator()(param_type p)
{ {
T t(p); T t(p);
contained<T> c(t); contained<T> c(t);
@ -128,7 +128,7 @@ void checker<T>::operator()(param_type p)
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T, std::size_t N> template <class T, std::size_t N>
struct checker<T[N]> struct call_traits_checker<T[N]>
{ {
typedef typename boost::call_traits<T[N]>::param_type param_type; typedef typename boost::call_traits<T[N]>::param_type param_type;
void operator()(param_type t) void operator()(param_type t)
@ -176,32 +176,32 @@ void check_make_pair(T c, U u, V v)
} }
struct UDT struct comparible_UDT
{ {
int i_; int i_;
UDT() : i_(2){} comparible_UDT() : i_(2){}
bool operator == (const UDT& v){ return v.i_ == i_; } bool operator == (const comparible_UDT& v){ return v.i_ == i_; }
}; };
int main() int main(int argc, char *argv[ ])
{ {
checker<UDT> c1; call_traits_checker<comparible_UDT> c1;
UDT u; comparible_UDT u;
c1(u); c1(u);
checker<int> c2; call_traits_checker<int> c2;
int i = 2; int i = 2;
c2(i); c2(i);
int* pi = &i; int* pi = &i;
#if defined(BOOST_MSVC6_MEMBER_TEMPLATES) || !defined(BOOST_NO_MEMBER_TEMPLATES) #if defined(BOOST_MSVC6_MEMBER_TEMPLATES) || !defined(BOOST_NO_MEMBER_TEMPLATES)
checker<int*> c3; call_traits_checker<int*> c3;
c3(pi); c3(pi);
checker<int&> c4; call_traits_checker<int&> c4;
c4(i); c4(i);
checker<const int&> c5; call_traits_checker<const int&> c5;
c5(i); c5(i);
#if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) #if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
int a[2] = {1,2}; int a[2] = {1,2};
checker<int[2]> c6; call_traits_checker<int[2]> c6;
c6(a); c6(a);
#endif #endif
#endif #endif
@ -220,10 +220,10 @@ int main()
typedef int& r_type; typedef int& r_type;
typedef const r_type cr_type; typedef const r_type cr_type;
type_test(UDT, boost::call_traits<UDT>::value_type) type_test(comparible_UDT, boost::call_traits<comparible_UDT>::value_type)
type_test(UDT&, boost::call_traits<UDT>::reference) type_test(comparible_UDT&, boost::call_traits<comparible_UDT>::reference)
type_test(const UDT&, boost::call_traits<UDT>::const_reference) type_test(const comparible_UDT&, boost::call_traits<comparible_UDT>::const_reference)
type_test(const UDT&, boost::call_traits<UDT>::param_type) type_test(const comparible_UDT&, boost::call_traits<comparible_UDT>::param_type)
type_test(int, boost::call_traits<int>::value_type) type_test(int, boost::call_traits<int>::value_type)
type_test(int&, boost::call_traits<int>::reference) type_test(int&, boost::call_traits<int>::reference)
type_test(const int&, boost::call_traits<int>::const_reference) type_test(const int&, boost::call_traits<int>::const_reference)
@ -271,9 +271,7 @@ int main()
test_count += 20; test_count += 20;
#endif #endif
std::cout << std::endl << test_count << " tests completed (" << failures << " failures)... press any key to exit"; return check_result(argc, argv);
std::cin.get();
return failures;
} }
// //
@ -364,3 +362,11 @@ template struct call_traits_test<int[2], true>;
#endif #endif
#endif #endif
#ifdef BOOST_MSVC
unsigned int expected_failures = 10;
#elif defined(__BORLANDC__)
unsigned int expected_failures = 2;
#else
unsigned int expected_failures = 0;
#endif

View File

@ -14,15 +14,10 @@
#include <cassert> #include <cassert>
#include <boost/compressed_pair.hpp> #include <boost/compressed_pair.hpp>
#include "type_traits_test.hpp" #include <boost/type_traits/type_traits_test.hpp>
using namespace boost; using namespace boost;
struct empty_POD_UDT{};
struct empty_UDT
{
~empty_UDT(){};
};
namespace boost { namespace boost {
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
template <> struct is_empty<empty_UDT> template <> struct is_empty<empty_UDT>
@ -59,7 +54,7 @@ struct non_empty2
{ return a.i == b.i; } { return a.i == b.i; }
}; };
int main() int main(int argc, char *argv[ ])
{ {
compressed_pair<int, double> cp1(1, 1.3); compressed_pair<int, double> cp1(1, 1.3);
assert(cp1.first() == 1); assert(cp1.first() == 1);
@ -107,9 +102,7 @@ int main()
value_test(true, (sizeof(compressed_pair<empty_UDT, empty_POD_UDT>) < sizeof(std::pair<empty_UDT, empty_POD_UDT>))) value_test(true, (sizeof(compressed_pair<empty_UDT, empty_POD_UDT>) < sizeof(std::pair<empty_UDT, empty_POD_UDT>)))
value_test(true, (sizeof(compressed_pair<empty_UDT, compressed_pair<empty_POD_UDT, int> >) < sizeof(std::pair<empty_UDT, std::pair<empty_POD_UDT, int> >))) value_test(true, (sizeof(compressed_pair<empty_UDT, compressed_pair<empty_POD_UDT, int> >) < sizeof(std::pair<empty_UDT, std::pair<empty_POD_UDT, int> >)))
std::cout << std::endl << test_count << " tests completed (" << failures << " failures)... press any key to exit"; return check_result(argc, argv);
std::cin.get();
return failures;
} }
// //
@ -154,6 +147,15 @@ template compressed_pair<double, int[2]>::compressed_pair();
#endif // __MWERKS__ #endif // __MWERKS__
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#ifdef __BORLANDC__
// can't handle both types empty:
unsigned int expected_failures = 1;
#elif defined(__GNUC__)
// no zero sized base classes:
unsigned int expected_failures = 4;
#else
unsigned int expected_failures = 0;
#endif

View File

@ -23,8 +23,11 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#endif #endif
#ifndef BOOST_TYPE_TRAITS_HPP #ifndef ARITHMETIC_TYPE_TRAITS_HPP
#include <boost/type_traits.hpp> #include <boost/type_traits/arithmetic_traits.hpp>
#endif
#ifndef COMPOSITE_TYPE_TRAITS_HPP
#include <boost/type_traits/composite_traits.hpp>
#endif #endif
namespace boost{ namespace boost{

View File

@ -19,8 +19,8 @@
#define BOOST_DETAIL_COMPRESSED_PAIR_HPP #define BOOST_DETAIL_COMPRESSED_PAIR_HPP
#include <algorithm> #include <algorithm>
#ifndef BOOST_TYPE_TRAITS_HPP #ifndef OBJECT_TYPE_TRAITS_HPP
#include <boost/type_traits.hpp> #include <boost/type_traits/object_traits.hpp>
#endif #endif
#ifndef BOOST_CALL_TRAITS_HPP #ifndef BOOST_CALL_TRAITS_HPP
#include <boost/call_traits.hpp> #include <boost/call_traits.hpp>

View File

@ -24,8 +24,11 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#endif #endif
#ifndef BOOST_TYPE_TRAITS_HPP #ifndef ARITHMETIC_TYPE_TRAITS_HPP
#include <boost/type_traits.hpp> #include <boost/type_traits/arithmetic_traits.hpp>
#endif
#ifndef COMPOSITE_TYPE_TRAITS_HPP
#include <boost/type_traits/composite_traits.hpp>
#endif #endif
namespace boost{ namespace boost{

View File

@ -26,8 +26,8 @@
#define BOOST_OB_COMPRESSED_PAIR_HPP #define BOOST_OB_COMPRESSED_PAIR_HPP
#include <algorithm> #include <algorithm>
#ifndef BOOST_TYPE_TRAITS_HPP #ifndef OBJECT_TYPE_TRAITS_HPP
#include <boost/type_traits.hpp> #include <boost/type_traits/object_traits.hpp>
#endif #endif
#ifndef BOOST_CALL_TRAITS_HPP #ifndef BOOST_CALL_TRAITS_HPP
#include <boost/call_traits.hpp> #include <boost/call_traits.hpp>