1 // Copyright (C) 2009-2013 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
;
37 bool test
__attribute__((unused
)) = true;
39 decimal32
a(11), b
, c
;
41 // Verify that we get the expected value of b after assignment.
43 ival
= LONGLONG (b
); VERIFY (ival
== 11);
45 // Check that the increment and decrement operators change the value
46 // of the original class.
49 ival
= LONGLONG (b
); VERIFY (ival
== 12);
53 ival
= LONGLONG (b
); VERIFY (ival
== 12);
57 ival
= LONGLONG (b
); VERIFY (ival
== 10);
61 ival
= LONGLONG (b
); VERIFY (ival
== 10);
63 // Check that the increment and decrement operators return the
67 ival
= LONGLONG (c
); VERIFY (ival
== 12);
71 ival
= LONGLONG (c
); VERIFY (ival
== 11);
75 ival
= LONGLONG (c
); VERIFY (ival
== 10);
79 ival
= LONGLONG (c
); VERIFY (ival
== 11);
85 bool test
__attribute__((unused
)) = true;
87 decimal64
a(11), b
, c
;
89 // Verify that we get the expected value of b after assignment.
91 ival
= LONGLONG (b
); VERIFY (ival
== 11);
93 // Check that the increment and decrement operators change the value
94 // of the original class.
97 ival
= LONGLONG (b
); VERIFY (ival
== 12);
101 ival
= LONGLONG (b
); VERIFY (ival
== 12);
105 ival
= LONGLONG (b
); VERIFY (ival
== 10);
109 ival
= LONGLONG (b
); VERIFY (ival
== 10);
111 // Check that the increment and decrement operators return the
115 ival
= LONGLONG (c
); VERIFY (ival
== 12);
119 ival
= LONGLONG (c
); VERIFY (ival
== 11);
123 ival
= LONGLONG (c
); VERIFY (ival
== 10);
127 ival
= LONGLONG (c
); VERIFY (ival
== 11);
133 bool test
__attribute__((unused
)) = true;
135 decimal128
a(11), b
, c
;
137 // Verify that we get the expected value of b after assignment.
139 ival
= LONGLONG (b
); VERIFY (ival
== 11);
141 // Check that the increment and decrement operators change the value
142 // of the original class.
145 ival
= LONGLONG (b
); VERIFY (ival
== 12);
149 ival
= LONGLONG (b
); VERIFY (ival
== 12);
153 ival
= LONGLONG (b
); VERIFY (ival
== 10);
157 ival
= LONGLONG (b
); VERIFY (ival
== 10);
159 // Check that the increment and decrement operators return the
163 ival
= LONGLONG (c
); VERIFY (ival
== 12);
167 ival
= LONGLONG (c
); VERIFY (ival
== 11);
171 ival
= LONGLONG (c
); VERIFY (ival
== 10);
175 ival
= LONGLONG (c
); VERIFY (ival
== 11);