]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / ratio / operations / ops1.cc
1 // { dg-do run { target c++11 } }
2
3 // 2008-07-03 Chris Fairles <chris.fairles@gmail.com>
4
5 // Copyright (C) 2008-2020 Free Software Foundation, Inc.
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 void
26 test01()
27 {
28 std::ratio_add<std::ratio<3,8>, std::ratio<5,12>>::type r;
29
30 VERIFY( r.num == 19 );
31 VERIFY( r.den == 24 );
32 }
33
34 void
35 test02()
36 {
37 std::ratio_subtract<std::ratio<3,8>, std::ratio<5,12>>::type r;
38
39 VERIFY( r.num == -1 );
40 VERIFY( r.den == 24 );
41 }
42
43 void
44 test03()
45 {
46 std::ratio_multiply<std::ratio<3,8>, std::ratio<5,12>>::type r;
47
48 VERIFY( r.num == 5 );
49 VERIFY( r.den == 32 );
50 }
51
52 void
53 test04()
54 {
55 std::ratio_divide<std::ratio<3,8>, std::ratio<5,12>>::type r;
56
57 VERIFY( r.num == 9 );
58 VERIFY( r.den == 10 );
59 }
60
61 int main()
62 {
63 test01();
64 test02();
65 test03();
66 test04();
67 return 0;
68 }