Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / ratio / operations / 45866.cc
blob3b6d5e2f5377d49863eceef8b200dee016961908
1 // { dg-options "-std=gnu++0x" }
2 // { dg-require-cstdint "" }
4 // 2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
6 // Copyright (C) 2010-2013 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.
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.
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/>.
23 #include <ratio>
24 #include <testsuite_hooks.h>
26 // libstdc++/45866
27 void test01()
29 bool test __attribute__((unused)) = true;
31 typedef std::ratio<1, 4>::type r_type1;
32 typedef std::ratio<3, 2>::type r_type2;
34 typedef std::ratio_add<r_type1, r_type2> ra_type;
36 VERIFY( ra_type::num == ra_type::type::num );
37 VERIFY( ra_type::den == ra_type::type::den );
38 VERIFY( ra_type::num == 7 );
39 VERIFY( ra_type::den == 4 );
41 typedef std::ratio_subtract<r_type1, r_type2> rs_type;
43 VERIFY( rs_type::num == rs_type::type::num );
44 VERIFY( rs_type::den == rs_type::type::den );
45 VERIFY( rs_type::num == -5 );
46 VERIFY( rs_type::den == 4 );
48 typedef std::ratio_multiply<r_type1, r_type2> rm_type;
50 VERIFY( rm_type::num == rm_type::type::num );
51 VERIFY( rm_type::den == rm_type::type::den );
52 VERIFY( rm_type::num == 3 );
53 VERIFY( rm_type::den == 8 );
55 typedef std::ratio_divide<r_type1, r_type2> rd_type;
57 VERIFY( rd_type::num == rd_type::type::num );
58 VERIFY( rd_type::den == rd_type::type::den );
59 VERIFY( rd_type::num == 1 );
60 VERIFY( rd_type::den == 6 );
63 int main()
65 test01();
66 return 0;