2 // Testing utilities for the tr1 testsuite.
4 // Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
22 #ifndef _GLIBCXX_TESTSUITE_TR1_H
23 #define _GLIBCXX_TESTSUITE_TR1_H
25 #include <ext/type_traits.h>
29 // For tr1/type_traits.
30 template<template<typename> class Category, typename Type>
32 test_category(bool value)
35 ret &= Category<Type>::value == value;
36 ret &= Category<const Type>::value == value;
37 ret &= Category<volatile Type>::value == value;
38 ret &= Category<const volatile Type>::value == value;
39 ret &= Category<Type>::type::value == value;
40 ret &= Category<const Type>::type::value == value;
41 ret &= Category<volatile Type>::type::value == value;
42 ret &= Category<const volatile Type>::type::value == value;
46 template<template<typename> class Property, typename Type>
48 test_property(typename Property<Type>::value_type value)
51 ret &= Property<Type>::value == value;
52 ret &= Property<Type>::type::value == value;
56 // For testing tr1/type_traits/extent, which has a second template
58 template<template<typename, unsigned> class Property,
62 test_property(typename Property<Type, Uint>::value_type value)
65 ret &= Property<Type, Uint>::value == value;
66 ret &= Property<Type, Uint>::type::value == value;
70 template<template<typename, typename> class Relationship,
71 typename Type1, typename Type2>
73 test_relationship(bool value)
76 ret &= Relationship<Type1, Type2>::value == value;
77 ret &= Relationship<Type1, Type2>::type::value == value;
83 typedef const ClassType cClassType;
84 typedef volatile ClassType vClassType;
85 typedef const volatile ClassType cvClassType;
87 class DerivedType : public ClassType { };
92 { operator int() const; };
96 virtual void rotate(int) = 0;
99 class PolymorphicClass
101 virtual void rotate(int);
104 class DerivedPolymorphic : public PolymorphicClass { };
106 class VirtualDestructorClass
108 virtual ~VirtualDestructorClass();
113 class IncompleteClass;
115 int truncate_float(float x) { return (int)x; }
116 long truncate_double(double x) { return (long)x; }
118 struct do_truncate_float_t
120 do_truncate_float_t()
125 do_truncate_float_t(const do_truncate_float_t&)
130 ~do_truncate_float_t()
135 int operator()(float x) { return (int)x; }
137 static int live_objects;
140 int do_truncate_float_t::live_objects = 0;
142 struct do_truncate_double_t
144 do_truncate_double_t()
149 do_truncate_double_t(const do_truncate_double_t&)
154 ~do_truncate_double_t()
159 long operator()(double x) { return (long)x; }
161 static int live_objects;
164 int do_truncate_double_t::live_objects = 0;
170 int foo() { return 1; }
171 int foo_c() const { return 2; }
172 int foo_v() volatile { return 3; }
173 int foo_cv() const volatile { return 4; }
176 // For use in 8_c_compatibility.
177 template<typename R, typename T>
178 typename __gnu_cxx::__enable_if<std::__are_same<R, T>::__value,
183 } // namespace __gnu_test
185 #endif // _GLIBCXX_TESTSUITE_TR1_H