]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/decimal/compound-assignment-memfunc.cc
1 // Copyright (C) 2009-2014 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.6 Compound assignment (decimal32).
21 // ISO/IEC TR 24733 3.2.3.6 Compound assignment (decimal64).
22 // ISO/IEC TR 24733 3.2.4.6 Compound assignment (decimal128).
24 // Access member functions directly.
26 #include <decimal/decimal>
27 #include <testsuite_hooks.h>
29 using namespace std::decimal
;
37 unsigned long ul
= 20;
39 unsigned long long ull
= 50;
42 compound_assignment_add_32 (void)
44 bool test
__attribute__((unused
)) = true;
45 decimal32
a (1000), b
;
47 b
= a
; b
.operator+=(d32
); VERIFY (b
== 1005);
48 b
= a
; b
.operator+=(d64
); VERIFY (b
== 990);
49 b
= a
; b
.operator+=(d128
); VERIFY (b
== 1025);
50 b
= a
; b
.operator+=(si
); VERIFY (b
== 998);
51 b
= a
; b
.operator+=(ui
); VERIFY (b
== 1005);
52 b
= a
; b
.operator+=(sl
); VERIFY (b
== 990);
53 b
= a
; b
.operator+=(ul
); VERIFY (b
== 1020);
54 b
= a
; b
.operator+=(sll
); VERIFY (b
== 975);
55 b
= a
; b
.operator+=(ull
); VERIFY (b
== 1050);
59 compound_assignment_subtract_32 (void)
61 bool test
__attribute__((unused
)) = true;
62 decimal32
a (1000), b
;
64 b
= a
; b
.operator-=(d32
); VERIFY (b
== 995);
65 b
= a
; b
.operator-=(d64
); VERIFY (b
== 1010);
66 b
= a
; b
.operator-=(d128
); VERIFY (b
== 975);
67 b
= a
; b
.operator-=(si
); VERIFY (b
== 1002);
68 b
= a
; b
.operator-=(ui
); VERIFY (b
== 995);
69 b
= a
; b
.operator-=(sl
); VERIFY (b
== 1010);
70 b
= a
; b
.operator-=(ul
); VERIFY (b
== 980);
71 b
= a
; b
.operator-=(sll
); VERIFY (b
== 1025);
72 b
= a
; b
.operator-=(ull
); VERIFY (b
== 950);
76 compound_assignment_multiply_32 (void)
78 bool test
__attribute__((unused
)) = true;
79 decimal32
a (1000), b
;
81 b
= a
; b
.operator*=(d32
); VERIFY (b
== 5000);
82 b
= a
; b
.operator*=(d64
); VERIFY (b
== -10000);
83 b
= a
; b
.operator*=(d128
); VERIFY (b
== 25000);
84 b
= a
; b
.operator*=(si
); VERIFY (b
== -2000);
85 b
= a
; b
.operator*=(ui
); VERIFY (b
== 5000);
86 b
= a
; b
.operator*=(sl
); VERIFY (b
== -10000);
87 b
= a
; b
.operator*=(ul
); VERIFY (b
== 20000);
88 b
= a
; b
.operator*=(sll
); VERIFY (b
== -25000);
89 b
= a
; b
.operator*=(ull
); VERIFY (b
== 50000);
93 compound_assignment_divide_32 (void)
95 bool test
__attribute__((unused
)) = true;
96 decimal32
a (1000), b
;
98 b
= a
; b
.operator/=(d32
); VERIFY (b
== 200);
99 b
= a
; b
.operator/=(d64
); VERIFY (b
== -100);
100 b
= a
; b
.operator/=(d128
); VERIFY (b
== 40);
101 b
= a
; b
.operator/=(si
); VERIFY (b
== -500);
102 b
= a
; b
.operator/=(ui
); VERIFY (b
== 200);
103 b
= a
; b
.operator/=(sl
); VERIFY (b
== -100);
104 b
= a
; b
.operator/=(ul
); VERIFY (b
== 50);
105 b
= a
; b
.operator/=(sll
); VERIFY (b
== -40);
106 b
= a
; b
.operator/=(ull
); VERIFY (b
== 20);
110 compound_assignment_add_64 (void)
112 bool test
__attribute__((unused
)) = true;
113 decimal64
a (1000), b
;
115 b
= a
; b
.operator+=(d32
); VERIFY (b
== 1005);
116 b
= a
; b
.operator+=(d64
); VERIFY (b
== 990);
117 b
= a
; b
.operator+=(d128
); VERIFY (b
== 1025);
118 b
= a
; b
.operator+=(si
); VERIFY (b
== 998);
119 b
= a
; b
.operator+=(ui
); VERIFY (b
== 1005);
120 b
= a
; b
.operator+=(sl
); VERIFY (b
== 990);
121 b
= a
; b
.operator+=(ul
); VERIFY (b
== 1020);
122 b
= a
; b
.operator+=(sll
); VERIFY (b
== 975);
123 b
= a
; b
.operator+=(ull
); VERIFY (b
== 1050);
127 compound_assignment_subtract_64 (void)
129 bool test
__attribute__((unused
)) = true;
130 decimal64
a (1000), b
;
132 b
= a
; b
.operator-=(d32
); VERIFY (b
== 995);
133 b
= a
; b
.operator-=(d64
); VERIFY (b
== 1010);
134 b
= a
; b
.operator-=(d128
); VERIFY (b
== 975);
135 b
= a
; b
.operator-=(si
); VERIFY (b
== 1002);
136 b
= a
; b
.operator-=(ui
); VERIFY (b
== 995);
137 b
= a
; b
.operator-=(sl
); VERIFY (b
== 1010);
138 b
= a
; b
.operator-=(ul
); VERIFY (b
== 980);
139 b
= a
; b
.operator-=(sll
); VERIFY (b
== 1025);
140 b
= a
; b
.operator-=(ull
); VERIFY (b
== 950);
144 compound_assignment_multiply_64 (void)
146 bool test
__attribute__((unused
)) = true;
147 decimal64
a (1000), b
;
149 b
= a
; b
.operator*=(d32
); VERIFY (b
== 5000);
150 b
= a
; b
.operator*=(d64
); VERIFY (b
== -10000);
151 b
= a
; b
.operator*=(d128
); VERIFY (b
== 25000);
152 b
= a
; b
.operator*=(si
); VERIFY (b
== -2000);
153 b
= a
; b
.operator*=(ui
); VERIFY (b
== 5000);
154 b
= a
; b
.operator*=(sl
); VERIFY (b
== -10000);
155 b
= a
; b
.operator*=(ul
); VERIFY (b
== 20000);
156 b
= a
; b
.operator*=(sll
); VERIFY (b
== -25000);
157 b
= a
; b
.operator*=(ull
); VERIFY (b
== 50000);
161 compound_assignment_divide_64 (void)
163 bool test
__attribute__((unused
)) = true;
164 decimal64
a (1000), b
;
166 b
= a
; b
.operator/=(d32
); VERIFY (b
== 200);
167 b
= a
; b
.operator/=(d64
); VERIFY (b
== -100);
168 b
= a
; b
.operator/=(d128
); VERIFY (b
== 40);
169 b
= a
; b
.operator/=(si
); VERIFY (b
== -500);
170 b
= a
; b
.operator/=(ui
); VERIFY (b
== 200);
171 b
= a
; b
.operator/=(sl
); VERIFY (b
== -100);
172 b
= a
; b
.operator/=(ul
); VERIFY (b
== 50);
173 b
= a
; b
.operator/=(sll
); VERIFY (b
== -40);
174 b
= a
; b
.operator/=(ull
); VERIFY (b
== 20);
178 compound_assignment_add_128 (void)
180 bool test
__attribute__((unused
)) = true;
181 decimal128
a (1000), b
;
183 b
= a
; b
.operator+=(d32
); VERIFY (b
== 1005);
184 b
= a
; b
.operator+=(d64
); VERIFY (b
== 990);
185 b
= a
; b
.operator+=(d128
); VERIFY (b
== 1025);
186 b
= a
; b
.operator+=(si
); VERIFY (b
== 998);
187 b
= a
; b
.operator+=(ui
); VERIFY (b
== 1005);
188 b
= a
; b
.operator+=(sl
); VERIFY (b
== 990);
189 b
= a
; b
.operator+=(ul
); VERIFY (b
== 1020);
190 b
= a
; b
.operator+=(sll
); VERIFY (b
== 975);
191 b
= a
; b
.operator+=(ull
); VERIFY (b
== 1050);
195 compound_assignment_subtract_128 (void)
197 bool test
__attribute__((unused
)) = true;
198 decimal128
a (1000), b
;
200 b
= a
; b
.operator-=(d32
); VERIFY (b
== 995);
201 b
= a
; b
.operator-=(d64
); VERIFY (b
== 1010);
202 b
= a
; b
.operator-=(d128
); VERIFY (b
== 975);
203 b
= a
; b
.operator-=(si
); VERIFY (b
== 1002);
204 b
= a
; b
.operator-=(ui
); VERIFY (b
== 995);
205 b
= a
; b
.operator-=(sl
); VERIFY (b
== 1010);
206 b
= a
; b
.operator-=(ul
); VERIFY (b
== 980);
207 b
= a
; b
.operator-=(sll
); VERIFY (b
== 1025);
208 b
= a
; b
.operator-=(ull
); VERIFY (b
== 950);
212 compound_assignment_multiply_128 (void)
214 bool test
__attribute__((unused
)) = true;
215 decimal128
a (1000), b
;
217 b
= a
; b
.operator*=(d32
); VERIFY (b
== 5000);
218 b
= a
; b
.operator*=(d64
); VERIFY (b
== -10000);
219 b
= a
; b
.operator*=(d128
); VERIFY (b
== 25000);
220 b
= a
; b
.operator*=(si
); VERIFY (b
== -2000);
221 b
= a
; b
.operator*=(ui
); VERIFY (b
== 5000);
222 b
= a
; b
.operator*=(sl
); VERIFY (b
== -10000);
223 b
= a
; b
.operator*=(ul
); VERIFY (b
== 20000);
224 b
= a
; b
.operator*=(sll
); VERIFY (b
== -25000);
225 b
= a
; b
.operator*=(ull
); VERIFY (b
== 50000);
229 compound_assignment_divide_128 (void)
231 bool test
__attribute__((unused
)) = true;
232 decimal128
a (1000), b
;
234 b
= a
; b
.operator/=(d32
); VERIFY (b
== 200);
235 b
= a
; b
.operator/=(d64
); VERIFY (b
== -100);
236 b
= a
; b
.operator/=(d128
); VERIFY (b
== 40);
237 b
= a
; b
.operator/=(si
); VERIFY (b
== -500);
238 b
= a
; b
.operator/=(ui
); VERIFY (b
== 200);
239 b
= a
; b
.operator/=(sl
); VERIFY (b
== -100);
240 b
= a
; b
.operator/=(ul
); VERIFY (b
== 50);
241 b
= a
; b
.operator/=(sll
); VERIFY (b
== -40);
242 b
= a
; b
.operator/=(ull
); VERIFY (b
== 20);
248 compound_assignment_add_32 ();
249 compound_assignment_subtract_32 ();
250 compound_assignment_multiply_32 ();
251 compound_assignment_divide_32 ();
253 compound_assignment_add_64 ();
254 compound_assignment_subtract_64 ();
255 compound_assignment_multiply_64 ();
256 compound_assignment_divide_64 ();
258 compound_assignment_add_128 ();
259 compound_assignment_subtract_128 ();
260 compound_assignment_multiply_128 ();
261 compound_assignment_divide_128 ();