1 // Copyright (C) 2009-2017 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 // Access member functions directly.
26 #include <decimal/decimal>
27 #include <testsuite_hooks.h>
29 // Use extension to replace implicit long long conversion with function call.
30 #define LONGLONG(X) decimal_to_long_long(X)
32 using namespace std::decimal
;
38 decimal32
a(11), b
, c
;
40 // Verify that we get the expected value of b after assignment.
42 ival
= LONGLONG (b
); VERIFY (ival
== 11);
44 // Check that the increment and decrement operators change the value
45 // of the original class.
48 ival
= LONGLONG (b
); VERIFY (ival
== 12);
52 ival
= LONGLONG (b
); VERIFY (ival
== 12);
56 ival
= LONGLONG (b
); VERIFY (ival
== 10);
60 ival
= LONGLONG (b
); VERIFY (ival
== 10);
62 // Check that the increment and decrement operators return the
66 ival
= LONGLONG (c
); VERIFY (ival
== 12);
70 ival
= LONGLONG (c
); VERIFY (ival
== 11);
74 ival
= LONGLONG (c
); VERIFY (ival
== 10);
78 ival
= LONGLONG (c
); VERIFY (ival
== 11);
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);
132 decimal128
a(11), b
, c
;
134 // Verify that we get the expected value of b after assignment.
136 ival
= LONGLONG (b
); VERIFY (ival
== 11);
138 // Check that the increment and decrement operators change the value
139 // of the original class.
142 ival
= LONGLONG (b
); VERIFY (ival
== 12);
146 ival
= LONGLONG (b
); VERIFY (ival
== 12);
150 ival
= LONGLONG (b
); VERIFY (ival
== 10);
154 ival
= LONGLONG (b
); VERIFY (ival
== 10);
156 // Check that the increment and decrement operators return the
160 ival
= LONGLONG (c
); VERIFY (ival
== 12);
164 ival
= LONGLONG (c
); VERIFY (ival
== 11);
168 ival
= LONGLONG (c
); VERIFY (ival
== 10);
172 ival
= LONGLONG (c
); VERIFY (ival
== 11);