1 // Copyright (C) 2009-2016 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-require-effective-target dfp }
20 // ISO/IEC TR 24733 3.2.2.5 Increment and decrement operators (decimal32).
21 // ISO/IEC TR 24733 3.2.3.5 Increment and decrement operators (decimal64).
22 // ISO/IEC TR 24733 3.2.4.5 Increment and decrement operators (decimal128).
24 #include <decimal/decimal>
25 #include <testsuite_hooks.h>
27 // Use extension to replace implicit long long conversion with function call.
28 #define LONGLONG(X) decimal_to_long_long(X)
30 using namespace std::decimal
;
35 bool test
__attribute__((unused
)) = true;
37 decimal32
a(11), b
, c
;
39 // Verify that we get the expected value of b after assignment.
41 ival
= LONGLONG (b
); VERIFY (ival
== 11);
43 // Check that the increment and decrement operators change the value
44 // of the original class.
47 ival
= LONGLONG (b
); VERIFY (ival
== 12);
51 ival
= LONGLONG (b
); VERIFY (ival
== 12);
55 ival
= LONGLONG (b
); VERIFY (ival
== 10);
59 ival
= LONGLONG (b
); VERIFY (ival
== 10);
61 // Check that the increment and decrement operators return the
65 ival
= LONGLONG (c
); VERIFY (ival
== 12);
69 ival
= LONGLONG (c
); VERIFY (ival
== 11);
73 ival
= LONGLONG (c
); VERIFY (ival
== 10);
77 ival
= LONGLONG (c
); VERIFY (ival
== 11);
83 bool test
__attribute__((unused
)) = true;
85 decimal64
a(11), b
, c
;
87 // Verify that we get the expected value of b after assignment.
89 ival
= LONGLONG (b
); VERIFY (ival
== 11);
91 // Check that the increment and decrement operators change the value
92 // of the original class.
95 ival
= LONGLONG (b
); VERIFY (ival
== 12);
99 ival
= LONGLONG (b
); VERIFY (ival
== 12);
103 ival
= LONGLONG (b
); VERIFY (ival
== 10);
107 ival
= LONGLONG (b
); VERIFY (ival
== 10);
109 // Check that the increment and decrement operators return the
113 ival
= LONGLONG (c
); VERIFY (ival
== 12);
117 ival
= LONGLONG (c
); VERIFY (ival
== 11);
121 ival
= LONGLONG (c
); VERIFY (ival
== 10);
125 ival
= LONGLONG (c
); VERIFY (ival
== 11);
131 bool test
__attribute__((unused
)) = true;
133 decimal128
a(11), b
, c
;
135 // Verify that we get the expected value of b after assignment.
137 ival
= LONGLONG (b
); VERIFY (ival
== 11);
139 // Check that the increment and decrement operators change the value
140 // of the original class.
143 ival
= LONGLONG (b
); VERIFY (ival
== 12);
147 ival
= LONGLONG (b
); VERIFY (ival
== 12);
151 ival
= LONGLONG (b
); VERIFY (ival
== 10);
155 ival
= LONGLONG (b
); VERIFY (ival
== 10);
157 // Check that the increment and decrement operators return the
161 ival
= LONGLONG (c
); VERIFY (ival
== 12);
165 ival
= LONGLONG (c
); VERIFY (ival
== 11);
169 ival
= LONGLONG (c
); VERIFY (ival
== 10);
173 ival
= LONGLONG (c
); VERIFY (ival
== 11);