]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/decimal/unary-arith.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / decimal / unary-arith.cc
CommitLineData
aa118a03 1// Copyright (C) 2009-2014 Free Software Foundation, Inc.
4cdc8761
BK
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
02ebbe2f 18// { dg-require-effective-target dfp }
4cdc8761
BK
19
20// ISO/IEC TR 24733 3.2.7 Unary arithmetic operators.
21
22#include <decimal/decimal>
23#include <testsuite_hooks.h>
24
25using namespace std::decimal;
26
27decimal32 a32 (20), b32 (-20);
28decimal64 a64 (124), b64 (-124);
29decimal128 a128 (5001), b128 (-5001);
30
31void
32unary_plus_32 (void)
33{
ef859c9d 34 bool test __attribute__((unused)) = true;
4cdc8761
BK
35 decimal32 a;
36
37 a = +a32; VERIFY (a == a32);
38 a = +b32; VERIFY (a == b32);
39}
40
41void
42unary_minus_32 (void)
43{
ef859c9d 44 bool test __attribute__((unused)) = true;
4cdc8761
BK
45 decimal32 a;
46
47 a = -a32; VERIFY (a == b32);
48 a = -b32; VERIFY (a == a32);
49}
50
51void
52unary_plus_64 (void)
53{
ef859c9d 54 bool test __attribute__((unused)) = true;
4cdc8761
BK
55 decimal64 a;
56
57 a = +a64; VERIFY (a == a64);
58 a = +b64; VERIFY (a == b64);
59}
60
61void
62unary_minus_64 (void)
63{
ef859c9d 64 bool test __attribute__((unused)) = true;
4cdc8761
BK
65 decimal64 a;
66
67 a = -a64; VERIFY (a == b64);
68 a = -b64; VERIFY (a == a64);
69}
70
71void
72unary_plus_128 (void)
73{
ef859c9d 74 bool test __attribute__((unused)) = true;
4cdc8761
BK
75 decimal128 a;
76
77 a = +a128; VERIFY (a == a128);
78 a = +b128; VERIFY (a == b128);
79}
80
81void
82unary_minus_128 (void)
83{
ef859c9d 84 bool test __attribute__((unused)) = true;
4cdc8761
BK
85 decimal128 a;
86
87 a = -a128; VERIFY (a == b128);
88 a = -b128; VERIFY (a == a128);
89}
90
91int main ()
92{
93 unary_plus_32 ();
94 unary_minus_32 ();
95 unary_plus_64 ();
96 unary_minus_64 ();
97 unary_plus_128 ();
98 unary_minus_128 ();
99}