]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/decimal/ctor.cc
Make use of extensions more explicit in libstdc++ tests
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / decimal / ctor.cc
1 // Copyright (C) 2009-2016 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
17
18 // { dg-require-effective-target dfp }
19 // { dg-options "-Wno-pedantic" }
20
21 // ISO/IEC TR 24733 3.2.2.1 Construct/copy/destroy (decimal32).
22 // ISO/IEC TR 24733 3.2.3.1 Construct/copy/destroy (decimal64).
23 // ISO/IEC TR 24733 3.2.4.1 Construct/copy/destroy (decimal128).
24
25 // Test the default constructor.
26
27 #include <decimal/decimal>
28 #include <cstring>
29 #include <testsuite_hooks.h>
30
31 using namespace std::decimal;
32
33 void
34 ctor_32 (void)
35 {
36 bool test __attribute__((unused)) = true;
37 decimal32 a;
38 float b __attribute__((mode(SD))) = 0.e-101DF;
39
40 VERIFY (std::memcmp (&a, &b, 4) == 0);
41 }
42
43 void
44 ctor_64 (void)
45 {
46 bool test __attribute__((unused)) = true;
47 decimal64 a;
48 float b __attribute__((mode(DD))) = 0.e-398DD;
49
50 VERIFY (std::memcmp (&a, &b, 8) == 0);
51 }
52
53 void
54 ctor_128 (void)
55 {
56 bool test __attribute__((unused)) = true;
57 decimal128 a;
58 float b __attribute__((mode(TD))) = 0.e-6176DL;
59
60 VERIFY (std::memcmp (&a, &b, 16) == 0);
61 }
62
63 int
64 main ()
65 {
66 ctor_32 ();
67 ctor_64 ();
68 ctor_128 ();
69 }