summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-25 18:17:06 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-02-25 18:17:06 +0000
commitb3264a6594c9116b2594244ab8d48dfd57c2d082 (patch)
tree49210fc23539041121c41b5c606fef5dfa83477e /libstdc++-v3/testsuite
parent7deb71e152bef5feace1842002352e8e6a953202 (diff)
downloadgcc-b3264a6594c9116b2594244ab8d48dfd57c2d082.tar.gz
2005-02-25 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits: Add the trivial is_union and is_class; add the __is_union_or_class extension. (is_enum, is_empty): Use the latter. * include/tr1/type_traits_fwd.h: Add __is_union_or_class. * testsuite/testsuite_tr1.h: Add UnionType; trivial formatting fixes. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_union_or_class/is_union_or_class.cc: New. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_union_or_class/typedefs.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95541 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/testsuite_tr1.h102
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc60
-rw-r--r--libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc36
3 files changed, 148 insertions, 50 deletions
diff --git a/libstdc++-v3/testsuite/testsuite_tr1.h b/libstdc++-v3/testsuite/testsuite_tr1.h
index 2a47483951c..3e9fafc434c 100644
--- a/libstdc++-v3/testsuite/testsuite_tr1.h
+++ b/libstdc++-v3/testsuite/testsuite_tr1.h
@@ -123,67 +123,69 @@ namespace __gnu_test
class AbstractClass
{ virtual void rotate(int) = 0; };
+ union UnionType { };
- int truncate_float(float x) { return (int)x; }
- long truncate_double(double x) { return (long)x; }
- struct do_truncate_float_t
- {
- do_truncate_float_t()
- {
- ++live_objects;
- }
-
- do_truncate_float_t(const do_truncate_float_t&)
- {
- ++live_objects;
- }
+ int truncate_float(float x) { return (int)x; }
+ long truncate_double(double x) { return (long)x; }
- ~do_truncate_float_t()
- {
- --live_objects;
- }
-
- int operator()(float x) { return (int)x; }
+ struct do_truncate_float_t
+ {
+ do_truncate_float_t()
+ {
+ ++live_objects;
+ }
- static int live_objects;
- };
+ do_truncate_float_t(const do_truncate_float_t&)
+ {
+ ++live_objects;
+ }
+
+ ~do_truncate_float_t()
+ {
+ --live_objects;
+ }
- int do_truncate_float_t::live_objects = 0;
+ int operator()(float x) { return (int)x; }
+
+ static int live_objects;
+ };
- struct do_truncate_double_t
- {
- do_truncate_double_t()
- {
- ++live_objects;
- }
+ int do_truncate_float_t::live_objects = 0;
- do_truncate_double_t(const do_truncate_double_t&)
- {
+ struct do_truncate_double_t
+ {
+ do_truncate_double_t()
+ {
++live_objects;
- }
-
- ~do_truncate_double_t()
- {
- --live_objects;
- }
-
- long operator()(double x) { return (long)x; }
-
- static int live_objects;
- };
+ }
- int do_truncate_double_t::live_objects = 0;
+ do_truncate_double_t(const do_truncate_double_t&)
+ {
+ ++live_objects;
+ }
- struct X
- {
- int bar;
+ ~do_truncate_double_t()
+ {
+ --live_objects;
+ }
- int foo() { return 1; }
- int foo_c() const { return 2; }
- int foo_v() volatile { return 3; }
- int foo_cv() const volatile { return 4; }
- };
+ long operator()(double x) { return (long)x; }
+
+ static int live_objects;
+ };
+
+ int do_truncate_double_t::live_objects = 0;
+
+ struct X
+ {
+ int bar;
+
+ int foo() { return 1; }
+ int foo_c() const { return 2; }
+ int foo_v() volatile { return 3; }
+ int foo_cv() const volatile { return 4; }
+ };
}; // namespace __gnu_test
#endif // _GLIBCXX_TESTSUITE_TR1_H
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc
new file mode 100644
index 00000000000..6027eb97386
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/is_union_or_class.cc
@@ -0,0 +1,60 @@
+// 2005-02-25 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 4.5.2 Composite type traits
+
+#include <tr1/type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::__is_union_or_class;
+ using namespace __gnu_test;
+
+ // Positive tests.
+ VERIFY( (test_category<__is_union_or_class, UnionType>(true)) );
+ VERIFY( (test_category<__is_union_or_class, ClassType>(true)) );
+ VERIFY( (test_category<__is_union_or_class, DerivedType>(true)) );
+ VERIFY( (test_category<__is_union_or_class, ConvType>(true)) );
+ VERIFY( (test_category<__is_union_or_class, AbstractClass>(true)) );
+
+ // Negative tests.
+ VERIFY( (test_category<__is_union_or_class, void>(false)) );
+ VERIFY( (test_category<__is_union_or_class, int>(false)) );
+ VERIFY( (test_category<__is_union_or_class, float>(false)) );
+ VERIFY( (test_category<__is_union_or_class, int[2]>(false)) );
+ VERIFY( (test_category<__is_union_or_class, int*>(false)) );
+ VERIFY( (test_category<__is_union_or_class, int(*)(int)>(false)) );
+ VERIFY( (test_category<__is_union_or_class, float&>(false)) );
+ VERIFY( (test_category<__is_union_or_class, float(&)(float)>(false)) );
+ VERIFY( (test_category<__is_union_or_class, int (ClassType::*)>(false)) );
+ VERIFY( (test_category<__is_union_or_class,
+ int (ClassType::*) (int)>(false)) );
+ VERIFY( (test_category<__is_union_or_class, int (int)>(false)) );
+ VERIFY( (test_category<__is_union_or_class, EnumType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc
new file mode 100644
index 00000000000..d62829afea8
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_union_or_class/typedefs.cc
@@ -0,0 +1,36 @@
+// 2005-02-25 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+//
+// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES.
+
+#include <tr1/type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::tr1::__is_union_or_class<int> test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}