github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/tests/cxx/t-ternary.cc (about)

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