]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/ratio/operations/45866.cc
1 // { dg-do run { target c++11 } }
3 // 2010-10-18 Paolo Carlini <paolo.carlini@oracle.com>
5 // Copyright (C) 2010-2024 Free Software Foundation, Inc.
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)
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.
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/>.
23 #include <testsuite_hooks.h>
28 typedef std::ratio
<1, 4>::type r_type1
;
29 typedef std::ratio
<3, 2>::type r_type2
;
31 typedef std::ratio_add
<r_type1
, r_type2
> ra_type
;
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 );
38 typedef std::ratio_subtract
<r_type1
, r_type2
> rs_type
;
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 );
45 typedef std::ratio_multiply
<r_type1
, r_type2
> rm_type
;
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 );
52 typedef std::ratio_divide
<r_type1
, r_type2
> rd_type
;
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 );