1/* Test mp*_class ternary expressions. 2 3Copyright 2001-2003 Free Software Foundation, Inc. 4 5This file is part of the GNU MP Library test suite. 6 7The GNU MP Library test suite is free software; you can redistribute it 8and/or modify it under the terms of the GNU General Public License as 9published by the Free Software Foundation; either version 3 of the License, 10or (at your option) any later version. 11 12The GNU MP Library test suite is distributed in the hope that it will be 13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15Public License for more details. 16 17You should have received a copy of the GNU General Public License along with 18the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */ 19 20#include "config.h" 21 22#include <iostream> 23 24#include "gmpxx.h" 25#include "gmp-impl.h" 26#include "tests.h" 27 28using namespace std; 29 30 31/* The various test cases are broken up into separate functions to keep down 32 compiler memory use. They're static so that any mistakenly omitted from 33 main() will provoke warnings (under gcc -Wall at least). */ 34 35static void 36check_mpz_1 (void) 37{ 38 // template<class Op1, class Op2> 39 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr 40 // <mpz_t, __gmp_binary_expr<mpz_class, mpz_class, Op1> >, Op2> > 41 { 42 mpz_class a(1), b(2), c(3); 43 mpz_class d; 44 d = a + b * c; ASSERT_ALWAYS(d == 7); 45 } 46 { 47 mpz_class a(1), b(2), c(3); 48 mpz_class d; 49 d = a - b * c; ASSERT_ALWAYS(d == -5); 50 } 51} 52 53static void 54check_mpz_2 (void) 55{ 56 // template <class T, class Op1, class Op2> 57 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr 58 // <mpz_t, __gmp_binary_expr<mpz_class, T, Op1> >, Op2> > 59 { 60 mpz_class a(1), b(2); 61 signed int c = 3; 62 mpz_class d; 63 d = a + b * c; ASSERT_ALWAYS(d == 7); 64 } 65 { 66 mpz_class a(1), b(2); 67 signed int c = 3; 68 mpz_class d; 69 d = a - b * c; ASSERT_ALWAYS(d == -5); 70 } 71} 72 73static void 74check_mpz_3 (void) 75{ 76 // template <class T, class Op1, class Op2> 77 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr 78 // <mpz_t, __gmp_binary_expr<T, mpz_class, Op1> >, Op2> > 79 { 80 mpz_class a(1), b(2); 81 unsigned int c = 3; 82 mpz_class d; 83 d = a + c * b; ASSERT_ALWAYS(d == 7); 84 } 85 { 86 mpz_class a(1), b(2); 87 unsigned int c = 3; 88 mpz_class d; 89 d = a - c * b; ASSERT_ALWAYS(d == -5); 90 } 91} 92 93static void 94check_mpz_4 (void) 95{ 96 // template <class T, class Op1, class Op2> 97 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr 98 // <mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr<mpz_t, T>, Op1> >, Op2> > 99 { 100 mpz_class a(1), b(2), c(3); 101 double d = 4.0; 102 mpz_class e; 103 e = a + b * (c + d); ASSERT_ALWAYS(e == 15); 104 } 105 { 106 mpz_class a(1), b(2), c(3); 107 double d = 4.0; 108 mpz_class e; 109 e = a - b * (c + d); ASSERT_ALWAYS(e == -13); 110 } 111} 112 113static void 114check_mpz_5 (void) 115{ 116 // template <class T, class Op1, class Op2> 117 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr 118 // <mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, mpz_class, Op1> >, Op2> > 119 { 120 mpz_class a(1), b(2), c(3); 121 signed int d = 4; 122 mpz_class e; 123 e = a + (b - d) * c; ASSERT_ALWAYS(e == -5); 124 } 125 { 126 mpz_class a(1), b(2), c(3); 127 signed int d = 4; 128 mpz_class e; 129 e = a - (b - d) * c; ASSERT_ALWAYS(e == 7); 130 } 131} 132 133static void 134check_mpz_6 (void) 135{ 136 // template <class T, class U, class Op1, class Op2> 137 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr 138 // <mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, U, Op1> >, Op2> > 139 { 140 mpz_class a(1), b(2); 141 unsigned int c = 3, d = 4; 142 mpz_class e; 143 e = a + (b + c) * d; ASSERT_ALWAYS(e == 21); 144 } 145 { 146 mpz_class a(1), b(2); 147 unsigned int c = 3, d = 4; 148 mpz_class e; 149 e = a - (b + c) * d; ASSERT_ALWAYS(e == -19); 150 } 151} 152 153static void 154check_mpz_7 (void) 155{ 156 // template <class T, class U, class Op1, class Op2> 157 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr 158 // <mpz_t, __gmp_binary_expr<T, __gmp_expr<mpz_t, U>, Op1> >, Op2> > 159 { 160 mpz_class a(1), b(2); 161 double c = 3.0, d = 4.0; 162 mpz_class e; 163 e = a + c * (b + d); ASSERT_ALWAYS(e == 19); 164 } 165 { 166 mpz_class a(1), b(2); 167 double c = 3.0, d = 4.0; 168 mpz_class e; 169 e = a - c * (b + d); ASSERT_ALWAYS(e == -17); 170 } 171} 172 173static void 174check_mpz_8 (void) 175{ 176 // template <class T, class U, class Op1, class Op2> 177 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr 178 // <mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, __gmp_expr<mpz_t, U>, 179 // Op1> >, Op2> > 180 { 181 mpz_class a(1), b(2), c(3); 182 signed int d = 4, e = 5; 183 mpz_class f; 184 f = a + (b - d) * (c + e); ASSERT_ALWAYS(f == -15); 185 } 186 { 187 mpz_class a(1), b(2), c(3); 188 signed int d = 4, e = 5; 189 mpz_class f; 190 f = a - (b - d) * (c + e); ASSERT_ALWAYS(f == 17); 191 } 192} 193 194static void 195check_mpz_9 (void) 196{ 197 // template <class T, class Op1, class Op2> 198 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, 199 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, mpz_class, Op1> >, Op2> > 200 { 201 mpz_class a(1), b(2), c(3); 202 unsigned int d = 4; 203 mpz_class e; 204 e = (a + d) + b * c; ASSERT_ALWAYS(e == 11); 205 } 206 { 207 mpz_class a(1), b(2), c(3); 208 unsigned int d = 4; 209 mpz_class e; 210 e = (a + d) - b * c; ASSERT_ALWAYS(e == -1); 211 } 212} 213 214static void 215check_mpz_10 (void) 216{ 217 // template <class T, class U, class Op1, class Op2> 218 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, 219 // __gmp_expr<mpz_t, __gmp_binary_expr<mpz_class, U, Op1> >, Op2> > 220 { 221 mpz_class a(1), b(2); 222 double c = 3.0, d = 4.0; 223 mpz_class e; 224 e = (a - c) + b * d; ASSERT_ALWAYS(e == 6); 225 } 226 { 227 mpz_class a(1), b(2); 228 double c = 3.0, d = 4.0; 229 mpz_class e; 230 e = (a - c) - b * d; ASSERT_ALWAYS(e == -10); 231 } 232} 233 234static void 235check_mpz_11 (void) 236{ 237 // template <class T, class U, class Op1, class Op2> 238 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, 239 // __gmp_expr<mpz_t, __gmp_binary_expr<U, mpz_class, Op1> >, Op2> > 240 { 241 mpz_class a(1), b(2); 242 signed int c = 3, d = 4; 243 mpz_class e; 244 e = (a - c) + d * b; ASSERT_ALWAYS(e == 6); 245 } 246 { 247 mpz_class a(1), b(2); 248 signed int c = 3, d = 4; 249 mpz_class e; 250 e = (a - c) - d * b; ASSERT_ALWAYS(e == -10); 251 } 252} 253 254static void 255check_mpz_12 (void) 256{ 257 // template <class T, class U, class Op1, class Op2> 258 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, __gmp_expr 259 // <mpz_t, __gmp_binary_expr<mpz_class, __gmp_expr<mpz_t, U>, Op1> >, Op2> > 260 { 261 mpz_class a(1), b(2), c(3); 262 unsigned int d = 4, e = 5; 263 mpz_class f; 264 f = (a + d) + b * (c - e); ASSERT_ALWAYS(f == 1); 265 } 266 { 267 mpz_class a(1), b(2), c(3); 268 unsigned int d = 4, e = 5; 269 mpz_class f; 270 f = (a + d) - b * (c - e); ASSERT_ALWAYS(f == 9); 271 } 272} 273 274static void 275check_mpz_13 (void) 276{ 277 // template <class T, class U, class Op1, class Op2> 278 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, __gmp_expr 279 // <mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, U>, mpz_class, Op1> >, Op2> > 280 { 281 mpz_class a(1), b(2), c(3); 282 double d = 4.0, e = 5.0; 283 mpz_class f; 284 f = (a - d) + (b + e) * c; ASSERT_ALWAYS(f == 18); 285 } 286 { 287 mpz_class a(1), b(2), c(3); 288 double d = 4.0, e = 5.0; 289 mpz_class f; 290 f = (a - d) - (b + e) * c; ASSERT_ALWAYS(f == -24); 291 } 292 293} 294 295static void 296check_mpz_14 (void) 297{ 298 // template <class T, class U, class V, class Op1, class Op2> 299 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, __gmp_expr 300 // <mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, U>, V, Op1> >, Op2> > 301 { 302 mpz_class a(1), b(2); 303 signed int c = 3, d = 4, e = 5; 304 mpz_class f; 305 f = (a + c) + (b + d) * e; ASSERT_ALWAYS(f == 34); 306 } 307 { 308 mpz_class a(1), b(2); 309 signed int c = 3, d = 4, e = 5; 310 mpz_class f; 311 f = (a + c) - (b + d) * e; ASSERT_ALWAYS(f == -26); 312 } 313} 314 315static void 316check_mpz_15 (void) 317{ 318 // template <class T, class U, class V, class Op1, class Op2> 319 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, __gmp_expr 320 // <mpz_t, __gmp_binary_expr<U, __gmp_expr<mpz_t, V>, Op1> >, Op2> > 321 { 322 mpz_class a(1), b(2); 323 unsigned int c = 3, d = 4, e = 5; 324 mpz_class f; 325 f = (a - c) + d * (b - e); ASSERT_ALWAYS(f == -14); 326 } 327 { 328 mpz_class a(1), b(2); 329 unsigned int c = 3, d = 4, e = 5; 330 mpz_class f; 331 f = (a - c) - d * (b - e); ASSERT_ALWAYS(f == 10); 332 } 333 334} 335 336static void 337check_mpz_16 (void) 338{ 339 // template <class T, class U, class V, class Op1, class Op2> 340 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, T>, __gmp_expr 341 // <mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, U>, __gmp_expr<mpz_t, V>, 342 // Op1> >, Op2> > 343 { 344 mpz_class a(1), b(2), c(3); 345 double d = 4.0, e = 5.0, f = 6.0; 346 mpz_class g; 347 g = (a + d) + (b - e) * (c + f); ASSERT_ALWAYS(g == -22); 348 } 349 { 350 mpz_class a(1), b(2), c(3); 351 double d = 4.0, e = 5.0, f = 6.0; 352 mpz_class g; 353 g = (a + d) - (b - e) * (c + f); ASSERT_ALWAYS(g == 32); 354 } 355} 356 357static void 358check_mpz_17 (void) 359{ 360 // template <class Op1, class Op2> 361 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr 362 // <mpz_t, __gmp_binary_expr<mpz_class, mpz_class, Op1> >, mpz_class, Op2> > 363 { 364 mpz_class a(2), b(3), c(4); 365 mpz_class d; 366 d = a * b + c; ASSERT_ALWAYS(d == 10); 367 } 368 { 369 mpz_class a(2), b(3), c(4); 370 mpz_class d; 371 d = a * b - c; ASSERT_ALWAYS(d == 2); 372 } 373} 374 375static void 376check_mpz_18 (void) 377{ 378 // template <class T, class Op1, class Op2> 379 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr 380 // <mpz_t, __gmp_binary_expr<mpz_class, T, Op1> >, mpz_class, Op2> > 381 { 382 mpz_class a(2), b(3); 383 signed int c = 4; 384 mpz_class d; 385 d = a * c + b; ASSERT_ALWAYS(d == 11); 386 } 387 { 388 mpz_class a(2), b(3); 389 signed int c = 4; 390 mpz_class d; 391 d = a * c - b; ASSERT_ALWAYS(d == 5); 392 } 393 394} 395 396static void 397check_mpz_19 (void) 398{ 399 // template <class T, class Op1, class Op2> 400 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr 401 // <mpz_t, __gmp_binary_expr<T, mpz_class, Op1> >, mpz_class, Op2> > 402 { 403 mpz_class a(2), b(3); 404 unsigned int c = 4; 405 mpz_class d; 406 d = c * a + b; ASSERT_ALWAYS(d == 11); 407 } 408 { 409 mpz_class a(2), b(3); 410 unsigned int c = 4; 411 mpz_class d; 412 d = c * a - b; ASSERT_ALWAYS(d == 5); 413 } 414} 415 416static void 417check_mpz_20 (void) 418{ 419 // template <class T, class Op1, class Op2> 420 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 421 // <mpz_class, __gmp_expr<mpz_t, T>, Op1> >, mpz_class, Op2> > 422 { 423 mpz_class a(2), b(3), c(4); 424 double d = 5.0; 425 mpz_class e; 426 e = a * (b + d) + c; ASSERT_ALWAYS(e == 20); 427 } 428 { 429 mpz_class a(2), b(3), c(4); 430 double d = 5.0; 431 mpz_class e; 432 e = a * (b + d) - c; ASSERT_ALWAYS(e == 12); 433 } 434} 435 436static void 437check_mpz_21 (void) 438{ 439 // template <class T, class Op1, class Op2> 440 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 441 // <__gmp_expr<mpz_t, T>, mpz_class, Op1> >, mpz_class, Op2> > 442 { 443 mpz_class a(2), b(3), c(4); 444 signed int d = 5; 445 mpz_class e; 446 e = (a - d) * b + c; ASSERT_ALWAYS(e == -5); 447 } 448 { 449 mpz_class a(2), b(3), c(4); 450 signed int d = 5; 451 mpz_class e; 452 e = (a - d) * b - c; ASSERT_ALWAYS(e == -13); 453 } 454} 455 456static void 457check_mpz_22 (void) 458{ 459 // template <class T, class U, class Op1, class Op2> 460 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 461 // <__gmp_expr<mpz_t, T>, U, Op1> >, mpz_class, Op2> > 462 { 463 mpz_class a(2), b(3); 464 unsigned int c = 4, d = 5; 465 mpz_class e; 466 e = (a + c) * d + b; ASSERT_ALWAYS(e == 33); 467 } 468 { 469 mpz_class a(2), b(3); 470 unsigned int c = 4, d = 5; 471 mpz_class e; 472 e = (a + c) * d - b; ASSERT_ALWAYS(e == 27); 473 } 474} 475 476static void 477check_mpz_23 (void) 478{ 479 // template <class T, class U, class Op1, class Op2> 480 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 481 // <T, __gmp_expr<mpz_t, U>, Op1> >, mpz_class, Op2> > 482 { 483 mpz_class a(2), b(3); 484 double c = 4.0, d = 5.0; 485 mpz_class e; 486 e = c * (a + d) + b; ASSERT_ALWAYS(e == 31); 487 } 488 { 489 mpz_class a(2), b(3); 490 double c = 4.0, d = 5.0; 491 mpz_class e; 492 e = c * (a + d) - b; ASSERT_ALWAYS(e == 25); 493 } 494 495} 496 497static void 498check_mpz_24 (void) 499{ 500 // template <class T, class U, class Op1, class Op2> 501 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 502 // <__gmp_expr<mpz_t, T>, __gmp_expr<mpz_t, U>, Op1> >, mpz_class, Op2> > 503 { 504 mpz_class a(2), b(3), c(4); 505 signed int d = 5, e = 6; 506 mpz_class f; 507 f = (a - d) * (b + e) + c; ASSERT_ALWAYS(f == -23); 508 } 509 { 510 mpz_class a(2), b(3), c(4); 511 signed int d = 5, e = 6; 512 mpz_class f; 513 f = (a - d) * (b + e) - c; ASSERT_ALWAYS(f == -31); 514 } 515} 516 517static void 518check_mpz_25 (void) 519{ 520 // template <class T, class Op1, class Op2> 521 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 522 // <mpz_class, mpz_class, Op1> >, __gmp_expr<mpz_t, T>, Op2> > 523 { 524 mpz_class a(2), b(3), c(4); 525 unsigned int d = 5; 526 mpz_class e; 527 e = a * b + (c - d); ASSERT_ALWAYS(e == 5); 528 } 529 { 530 mpz_class a(2), b(3), c(4); 531 unsigned int d = 5; 532 mpz_class e; 533 e = a * b - (c - d); ASSERT_ALWAYS(e == 7); 534 } 535} 536 537static void 538check_mpz_26 (void) 539{ 540 // template <class T, class U, class Op1, class Op2> 541 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 542 // <mpz_class, T, Op1> >, __gmp_expr<mpz_t, U>, Op2> > 543 { 544 mpz_class a(2), b(3); 545 double c = 4.0, d = 5.0; 546 mpz_class e; 547 e = a * c + (b + d); ASSERT_ALWAYS(e == 16); 548 } 549 { 550 mpz_class a(2), b(3); 551 double c = 4.0, d = 5.0; 552 mpz_class e; 553 e = a * c - (b + d); ASSERT_ALWAYS(e == 0); 554 } 555} 556 557static void 558check_mpz_27 (void) 559{ 560 // template <class T, class U, class Op1, class Op2> 561 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 562 // <T, mpz_class, Op1> >, __gmp_expr<mpz_t, U>, Op2> > 563 { 564 mpz_class a(2), b(3); 565 signed int c = 4, d = 5; 566 mpz_class e; 567 e = c * a + (b - d); ASSERT_ALWAYS(e == 6); 568 } 569 { 570 mpz_class a(2), b(3); 571 signed int c = 4, d = 5; 572 mpz_class e; 573 e = c * a - (b - d); ASSERT_ALWAYS(e == 10); 574 } 575} 576 577static void 578check_mpz_28 (void) 579{ 580 // template <class T, class U, class Op1, class Op2> 581 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 582 // <mpz_class, __gmp_expr<mpz_t, T>, Op1> >, __gmp_expr<mpz_t, U>, Op2> > 583 { 584 mpz_class a(2), b(3), c(4); 585 unsigned int d = 5, e = 6; 586 mpz_class f; 587 f = a * (b - d) + (c + e); ASSERT_ALWAYS(f == 6); 588 } 589 { 590 mpz_class a(2), b(3), c(4); 591 unsigned int d = 5, e = 6; 592 mpz_class f; 593 f = a * (b - d) - (c + e); ASSERT_ALWAYS(f == -14); 594 } 595} 596 597static void 598check_mpz_29 (void) 599{ 600 // template <class T, class U, class Op1, class Op2> 601 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 602 // <__gmp_expr<mpz_t, T>, mpz_class, Op1> >, __gmp_expr<mpz_t, U>, Op2> > 603 { 604 mpz_class a(2), b(3), c(4); 605 double d = 5.0, e = 6.0; 606 mpz_class f; 607 f = (a + d) * b + (c - e); ASSERT_ALWAYS(f == 19); 608 } 609 { 610 mpz_class a(2), b(3), c(4); 611 double d = 5.0, e = 6.0; 612 mpz_class f; 613 f = (a + d) * b - (c - e); ASSERT_ALWAYS(f == 23); 614 } 615} 616 617static void 618check_mpz_30 (void) 619{ 620 // template <class T, class U, class V, class Op1, class Op2> 621 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 622 // <__gmp_expr<mpz_t, T>, U, Op1> >, __gmp_expr<mpz_t, V>, Op2> > 623 { 624 mpz_class a(2), b(3); 625 signed int c = 4, d = 5, e = 6; 626 mpz_class f; 627 f = (a + c) * d + (b + e); ASSERT_ALWAYS(f == 39); 628 } 629 { 630 mpz_class a(2), b(3); 631 signed int c = 4, d = 5, e = 6; 632 mpz_class f; 633 f = (a + c) * d - (b + e); ASSERT_ALWAYS(f == 21); 634 } 635} 636 637static void 638check_mpz_31 (void) 639{ 640 // template <class T, class U, class V, class Op1, class Op2> 641 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 642 // <T, __gmp_expr<mpz_t, U>, Op1> >, __gmp_expr<mpz_t, V>, Op2> > 643 { 644 mpz_class a(2), b(3); 645 unsigned int c = 4, d = 5, e = 6; 646 mpz_class f; 647 f = c * (a + d) + (b - e); ASSERT_ALWAYS(f == 25); 648 } 649 { 650 mpz_class a(2), b(3); 651 unsigned int c = 4, d = 5, e = 6; 652 mpz_class f; 653 f = c * (a + d) - (b - e); ASSERT_ALWAYS(f == 31); 654 } 655} 656 657static void 658check_mpz_32 (void) 659{ 660 // template <class T, class U, class V, class Op1, class Op2> 661 // __gmp_expr<mpz_t, __gmp_binary_expr<__gmp_expr<mpz_t, __gmp_binary_expr 662 // <__gmp_expr<mpz_t, T>, __gmp_expr<mpz_t, U>, Op1> >, 663 // __gmp_expr<mpz_t, V>, Op2> > 664 { 665 mpz_class a(2), b(3), c(4); 666 double d = 5.0, e = 6.0, f = 7.0; 667 mpz_class g; 668 g = (a + d) * (b - e) + (c + f); ASSERT_ALWAYS(g == -10); 669 } 670 { 671 mpz_class a(2), b(3), c(4); 672 double d = 5.0, e = 6.0, f = 7.0; 673 mpz_class g; 674 g = (a + d) * (b - e) - (c + f); ASSERT_ALWAYS(g == -32); 675 } 676} 677 678void 679check_mpq (void) 680{ 681 // currently there's no ternary mpq operation 682} 683 684void 685check_mpf (void) 686{ 687 // currently there's no ternary mpf operation 688} 689 690 691int 692main (void) 693{ 694 tests_start(); 695 696 check_mpz_1 (); 697 check_mpz_2 (); 698 check_mpz_3 (); 699 check_mpz_4 (); 700 check_mpz_5 (); 701 check_mpz_6 (); 702 check_mpz_7 (); 703 check_mpz_8 (); 704 check_mpz_9 (); 705 check_mpz_10 (); 706 check_mpz_11 (); 707 check_mpz_12 (); 708 check_mpz_13 (); 709 check_mpz_14 (); 710 check_mpz_15 (); 711 check_mpz_16 (); 712 check_mpz_17 (); 713 check_mpz_18 (); 714 check_mpz_19 (); 715 check_mpz_20 (); 716 check_mpz_21 (); 717 check_mpz_22 (); 718 check_mpz_23 (); 719 check_mpz_24 (); 720 check_mpz_25 (); 721 check_mpz_26 (); 722 check_mpz_27 (); 723 check_mpz_28 (); 724 check_mpz_29 (); 725 check_mpz_30 (); 726 check_mpz_31 (); 727 check_mpz_32 (); 728 729 check_mpq(); 730 check_mpf(); 731 732 tests_end(); 733 return 0; 734} 735