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