1 // { dg-options "-std=gnu++0x" }
2 // { dg-require-cstdint "" }
3
4 // 2008-07-03 Chris Fairles <chris.fairles@gmail.com>
5
6 // Copyright (C) 2008-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.
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 void
test01()27 test01()
28 {
29 bool test __attribute__((unused)) = true;
30
31 std::ratio_add<std::ratio<3,8>, std::ratio<5,12>>::type r;
32
33 VERIFY( r.num == 19 );
34 VERIFY( r.den == 24 );
35 }
36
37 void
test02()38 test02()
39 {
40 bool test __attribute__((unused)) = true;
41 std::ratio_subtract<std::ratio<3,8>, std::ratio<5,12>>::type r;
42
43 VERIFY( r.num == -1 );
44 VERIFY( r.den == 24 );
45 }
46
47 void
test03()48 test03()
49 {
50 bool test __attribute__((unused)) = true;
51 std::ratio_multiply<std::ratio<3,8>, std::ratio<5,12>>::type r;
52
53 VERIFY( r.num == 5 );
54 VERIFY( r.den == 32 );
55 }
56
57 void
test04()58 test04()
59 {
60 bool test __attribute__((unused)) = true;
61 std::ratio_divide<std::ratio<3,8>, std::ratio<5,12>>::type r;
62
63 VERIFY( r.num == 9 );
64 VERIFY( r.den == 10 );
65 }
66
main()67 int main()
68 {
69 test01();
70 test02();
71 test03();
72 test04();
73 return 0;
74 }
75