1 // { dg-do run { target c++11 } } 2 // { dg-require-cstdint "" } 3 4 // 2010-10-18 Paolo Carlini <paolo.carlini@oracle.com> 5 6 // Copyright (C) 2010-2018 Free Software Foundation, Inc. 7 // 8 // This file is part of the GNU ISO C++ Library. This library is free 9 // software; you can redistribute it and/or modify it under the 10 // terms of the GNU General Public License as published by the 11 // Free Software Foundation; either version 3, or (at your option) 12 // any later version. 13 14 // This library is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 19 // You should have received a copy of the GNU General Public License 20 // along with this library; see the file COPYING3. If not see 21 // <http://www.gnu.org/licenses/>. 22 23 #include <ratio> 24 #include <testsuite_hooks.h> 25 26 // libstdc++/45866 test01()27void test01() 28 { 29 typedef std::ratio<1, 4>::type r_type1; 30 typedef std::ratio<3, 2>::type r_type2; 31 32 typedef std::ratio_add<r_type1, r_type2> ra_type; 33 34 VERIFY( ra_type::num == ra_type::type::num ); 35 VERIFY( ra_type::den == ra_type::type::den ); 36 VERIFY( ra_type::num == 7 ); 37 VERIFY( ra_type::den == 4 ); 38 39 typedef std::ratio_subtract<r_type1, r_type2> rs_type; 40 41 VERIFY( rs_type::num == rs_type::type::num ); 42 VERIFY( rs_type::den == rs_type::type::den ); 43 VERIFY( rs_type::num == -5 ); 44 VERIFY( rs_type::den == 4 ); 45 46 typedef std::ratio_multiply<r_type1, r_type2> rm_type; 47 48 VERIFY( rm_type::num == rm_type::type::num ); 49 VERIFY( rm_type::den == rm_type::type::den ); 50 VERIFY( rm_type::num == 3 ); 51 VERIFY( rm_type::den == 8 ); 52 53 typedef std::ratio_divide<r_type1, r_type2> rd_type; 54 55 VERIFY( rd_type::num == rd_type::type::num ); 56 VERIFY( rd_type::den == rd_type::type::den ); 57 VERIFY( rd_type::num == 1 ); 58 VERIFY( rd_type::den == 6 ); 59 } 60 main()61int main() 62 { 63 test01(); 64 return 0; 65 } 66