From: Paolo Carlini <paolo.carlini@oracle.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: libstdc++ <libstdc++@gcc.gnu.org>
Subject: [v3] Add some type_traits tests
Date: Tue, 23 Mar 2010 15:22:00 -0000 [thread overview]
Message-ID: <4BA8D88F.4050001@oracle.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 83 bytes --]
Hi,
tested x86_64-linux, committed to mainline.
Paolo.
////////////////////////
[-- Attachment #2: CL_tests --]
[-- Type: text/plain, Size: 208 bytes --]
2010-03-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/20_util/is_trivial/value.cc: New.
* testsuite/20_util/is_standard_layout/value.cc: Likewise.
* testsuite/20_util/is_pod/value.cc: Extend.
[-- Attachment #3: patch_tests --]
[-- Type: text/plain, Size: 5238 bytes --]
Index: testsuite/20_util/is_trivial/value.cc
===================================================================
--- testsuite/20_util/is_trivial/value.cc (revision 0)
+++ testsuite/20_util/is_trivial/value.cc (revision 0)
@@ -0,0 +1,70 @@
+// { dg-options "-std=gnu++0x" }
+// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+struct NType // neither trivial nor standard-layout
+{
+ int i;
+ int j;
+ virtual ~NType();
+};
+
+struct TType // trivial but not standard-layout
+{
+ int i;
+
+private:
+ int j;
+};
+
+struct SLType // standard-layout but not trivial
+{
+ int i;
+ int j;
+ ~SLType();
+};
+
+struct PODType // both trivial and standard-layout
+{
+ int i;
+ int j;
+};
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::is_trivial;
+ using namespace __gnu_test;
+
+ VERIFY( (test_category<is_trivial, TType>(true)) );
+ VERIFY( (test_category<is_trivial, PODType>(true)) );
+
+ VERIFY( (test_category<is_trivial, NType>(false)) );
+ VERIFY( (test_category<is_trivial, SLType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
Index: testsuite/20_util/is_pod/value.cc
===================================================================
--- testsuite/20_util/is_pod/value.cc (revision 157668)
+++ testsuite/20_util/is_pod/value.cc (working copy)
@@ -22,6 +22,34 @@
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
+struct NType // neither trivial nor standard-layout
+{
+ int i;
+ int j;
+ virtual ~NType();
+};
+
+struct TType // trivial but not standard-layout
+{
+ int i;
+
+private:
+ int j;
+};
+
+struct SLType // standard-layout but not trivial
+{
+ int i;
+ int j;
+ ~SLType();
+};
+
+struct PODType // both trivial and standard-layout
+{
+ int i;
+ int j;
+};
+
void test01()
{
bool test __attribute__((unused)) = true;
@@ -43,8 +71,12 @@
VERIFY( (test_category<is_pod, int (ClassType::*[2][3])>(true)) );
VERIFY( (test_category<is_pod, int (ClassType::*[][2][3]) (int)>(true)) );
VERIFY( (test_category<is_pod, ClassType>(true)) );
+ VERIFY( (test_category<is_pod, PODType>(true)) );
VERIFY( (test_category<is_pod, void>(false)) );
+ VERIFY( (test_category<is_pod, NType>(false)) );
+ VERIFY( (test_category<is_pod, TType>(false)) );
+ VERIFY( (test_category<is_pod, SLType>(false)) );
}
int main()
Index: testsuite/20_util/is_standard_layout/value.cc
===================================================================
--- testsuite/20_util/is_standard_layout/value.cc (revision 0)
+++ testsuite/20_util/is_standard_layout/value.cc (revision 0)
@@ -0,0 +1,70 @@
+// { dg-options "-std=gnu++0x" }
+// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+struct NType // neither trivial nor standard-layout
+{
+ int i;
+ int j;
+ virtual ~NType();
+};
+
+struct TType // trivial but not standard-layout
+{
+ int i;
+
+private:
+ int j;
+};
+
+struct SLType // standard-layout but not trivial
+{
+ int i;
+ int j;
+ ~SLType();
+};
+
+struct PODType // both trivial and standard-layout
+{
+ int i;
+ int j;
+};
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::is_standard_layout;
+ using namespace __gnu_test;
+
+ VERIFY( (test_category<is_standard_layout, SLType>(true)) );
+ VERIFY( (test_category<is_standard_layout, PODType>(true)) );
+
+ VERIFY( (test_category<is_standard_layout, NType>(false)) );
+ VERIFY( (test_category<is_standard_layout, TType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
next reply other threads:[~2010-03-23 15:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-23 15:22 Paolo Carlini [this message]
2010-03-23 15:58 ` Paolo Carlini
-- strict thread matches above, loose matches on Subject: below --
2010-02-21 11:08 Paolo Carlini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BA8D88F.4050001@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).