1 /* Test legality of conversion between the different mp*_class 2 3 Copyright 2011 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 "gmpxx.h" 23 #include "gmp-impl.h" 24 #include "tests.h" 25 f_z(mpz_class)26int f_z (mpz_class){return 0;} f_q(mpq_class)27int f_q (mpq_class){return 1;} f_f(mpf_class)28int f_f (mpf_class){return 2;} f_zq(mpz_class)29int f_zq (mpz_class){return 0;} f_zq(mpq_class)30int f_zq (mpq_class){return 1;} f_zf(mpz_class)31int f_zf (mpz_class){return 0;} f_zf(mpf_class)32int f_zf (mpf_class){return 2;} f_qf(mpq_class)33int f_qf (mpq_class){return 1;} f_qf(mpf_class)34int f_qf (mpf_class){return 2;} f_zqf(mpz_class)35int f_zqf(mpz_class){return 0;} f_zqf(mpq_class)36int f_zqf(mpq_class){return 1;} f_zqf(mpf_class)37int f_zqf(mpf_class){return 2;} 38 39 void check(void)40check (void) 41 { 42 mpz_class z=42; 43 mpq_class q=33; 44 mpf_class f=18; 45 46 ASSERT_ALWAYS(f_z (z)==0); ASSERT_ALWAYS(f_z (-z)==0); 47 ASSERT_ALWAYS(f_q (z)==1); ASSERT_ALWAYS(f_q (-z)==1); 48 ASSERT_ALWAYS(f_q (q)==1); ASSERT_ALWAYS(f_q (-q)==1); 49 ASSERT_ALWAYS(f_f (z)==2); ASSERT_ALWAYS(f_f (-z)==2); 50 ASSERT_ALWAYS(f_f (q)==2); ASSERT_ALWAYS(f_f (-q)==2); 51 ASSERT_ALWAYS(f_f (f)==2); ASSERT_ALWAYS(f_f (-f)==2); 52 ASSERT_ALWAYS(f_zq (z)==0); 53 ASSERT_ALWAYS(f_zq (q)==1); ASSERT_ALWAYS(f_zq (-q)==1); 54 ASSERT_ALWAYS(f_zf (z)==0); 55 ASSERT_ALWAYS(f_zf (f)==2); ASSERT_ALWAYS(f_zf (-f)==2); 56 ASSERT_ALWAYS(f_qf (q)==1); 57 ASSERT_ALWAYS(f_qf (f)==2); ASSERT_ALWAYS(f_qf (-f)==2); 58 ASSERT_ALWAYS(f_zqf(z)==0); 59 ASSERT_ALWAYS(f_zqf(q)==1); 60 ASSERT_ALWAYS(f_zqf(f)==2); ASSERT_ALWAYS(f_zqf(-f)==2); 61 62 ASSERT_ALWAYS(f_zqf(mpz_class(z))==0); ASSERT_ALWAYS(f_zqf(mpz_class(-z))==0); 63 ASSERT_ALWAYS(f_zqf(mpz_class(q))==0); ASSERT_ALWAYS(f_zqf(mpz_class(-q))==0); 64 ASSERT_ALWAYS(f_zqf(mpz_class(f))==0); ASSERT_ALWAYS(f_zqf(mpz_class(-f))==0); 65 ASSERT_ALWAYS(f_zqf(mpq_class(z))==1); ASSERT_ALWAYS(f_zqf(mpq_class(-z))==1); 66 ASSERT_ALWAYS(f_zqf(mpq_class(q))==1); ASSERT_ALWAYS(f_zqf(mpq_class(-q))==1); 67 ASSERT_ALWAYS(f_zqf(mpq_class(f))==1); ASSERT_ALWAYS(f_zqf(mpq_class(-f))==1); 68 ASSERT_ALWAYS(f_zqf(mpf_class(z))==2); ASSERT_ALWAYS(f_zqf(mpf_class(-z))==2); 69 ASSERT_ALWAYS(f_zqf(mpf_class(q))==2); ASSERT_ALWAYS(f_zqf(mpf_class(-q))==2); 70 ASSERT_ALWAYS(f_zqf(mpf_class(f))==2); ASSERT_ALWAYS(f_zqf(mpf_class(-f))==2); 71 } 72 73 int main(void)74main (void) 75 { 76 tests_start(); 77 78 check(); 79 80 tests_end(); 81 return 0; 82 } 83