1 // Copyright (C) 2009-2018 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
;
36 decimal32
a(11), b
, c
;
38 // Verify that we get the expected value of b after assignment.
40 ival
= LONGLONG (b
); VERIFY (ival
== 11);
42 // Check that the increment and decrement operators change the value
43 // of the original class.
46 ival
= LONGLONG (b
); VERIFY (ival
== 12);
50 ival
= LONGLONG (b
); VERIFY (ival
== 12);
54 ival
= LONGLONG (b
); VERIFY (ival
== 10);
58 ival
= LONGLONG (b
); VERIFY (ival
== 10);
60 // Check that the increment and decrement operators return the
64 ival
= LONGLONG (c
); VERIFY (ival
== 12);
68 ival
= LONGLONG (c
); VERIFY (ival
== 11);
72 ival
= LONGLONG (c
); VERIFY (ival
== 10);
76 ival
= LONGLONG (c
); VERIFY (ival
== 11);
83 decimal64
a(11), b
, c
;
85 // Verify that we get the expected value of b after assignment.
87 ival
= LONGLONG (b
); VERIFY (ival
== 11);
89 // Check that the increment and decrement operators change the value
90 // of the original class.
93 ival
= LONGLONG (b
); VERIFY (ival
== 12);
97 ival
= LONGLONG (b
); VERIFY (ival
== 12);
101 ival
= LONGLONG (b
); VERIFY (ival
== 10);
105 ival
= LONGLONG (b
); VERIFY (ival
== 10);
107 // Check that the increment and decrement operators return the
111 ival
= LONGLONG (c
); VERIFY (ival
== 12);
115 ival
= LONGLONG (c
); VERIFY (ival
== 11);
119 ival
= LONGLONG (c
); VERIFY (ival
== 10);
123 ival
= LONGLONG (c
); VERIFY (ival
== 11);
130 decimal128
a(11), b
, c
;
132 // Verify that we get the expected value of b after assignment.
134 ival
= LONGLONG (b
); VERIFY (ival
== 11);
136 // Check that the increment and decrement operators change the value
137 // of the original class.
140 ival
= LONGLONG (b
); VERIFY (ival
== 12);
144 ival
= LONGLONG (b
); VERIFY (ival
== 12);
148 ival
= LONGLONG (b
); VERIFY (ival
== 10);
152 ival
= LONGLONG (b
); VERIFY (ival
== 10);
154 // Check that the increment and decrement operators return the
158 ival
= LONGLONG (c
); VERIFY (ival
== 12);
162 ival
= LONGLONG (c
); VERIFY (ival
== 11);
166 ival
= LONGLONG (c
); VERIFY (ival
== 10);
170 ival
= LONGLONG (c
); VERIFY (ival
== 11);