1 // { dg-options "-std=gnu++0x" }
2 // { dg-require-cstdint "" }
3
4 // Copyright (C) 2008-2013 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License
18 // along with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <ratio>
22 #include <testsuite_hooks.h>
23
24 void
test01()25 test01()
26 {
27 bool test __attribute__((unused)) = true;
28
29 VERIFY(( std::ratio_equal<std::ratio<2,6>, std::ratio<1,3>>::value == 1 ));
30 VERIFY(( std::ratio_equal<std::ratio<2,6>, std::ratio<1,4>>::value == 0 ));
31
32 VERIFY( (std::ratio_not_equal<std::ratio<2,6>,
33 std::ratio<1,3>>::value == 0) );
34 VERIFY( (std::ratio_not_equal<std::ratio<2,6>,
35 std::ratio<1,4>>::value == 1) );
36 }
37
38 void
test02()39 test02()
40 {
41 bool test __attribute__((unused)) = true;
42
43 VERIFY( (std::ratio_less<std::ratio<1,4>, std::ratio<1,3>>::value == 1) );
44 VERIFY( (std::ratio_less<std::ratio<-1,3>, std::ratio<1,3>>::value == 1) );
45
46 VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<1,4>>::value == 0) );
47 VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<-1,3>>::value == 0) );
48
49 VERIFY( (std::ratio_less<std::ratio<-1,3>, std::ratio<-1,4>>::value == 1) );
50 VERIFY( (std::ratio_less<std::ratio<0,4>, std::ratio<0,3>>::value == 0) );
51 VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<0,3>>::value == 0) );
52 VERIFY( (std::ratio_less<std::ratio<0,3>, std::ratio<-1,4>>::value == 0) );
53
54 VERIFY( (std::ratio_less_equal<std::ratio<-1,3>,
55 std::ratio<-1,3>>::value == 1) );
56 VERIFY( ( std::ratio_less_equal<std::ratio<1,4>,
57 std::ratio<1,3>>::value == 1) );
58
59 VERIFY( (std::ratio_less_equal<std::ratio<1,4>,
60 std::ratio<-1,3>>::value == 0) );
61 VERIFY( (std::ratio_less_equal<std::ratio<1,3>,
62 std::ratio<-1,3>>::value == 0) );
63
64 VERIFY( (std::ratio_greater<std::ratio<1,3>, std::ratio<1,4>>::value == 1) );
65 VERIFY( (std::ratio_greater<std::ratio<1,3>, std::ratio<-1,3>>::value == 1) );
66
67 VERIFY( (std::ratio_greater<std::ratio<1,4>, std::ratio<1,3>>::value == 0) );
68 VERIFY( (std::ratio_greater<std::ratio<-1,3>, std::ratio<1,3>>::value == 0) );
69
70 VERIFY( (std::ratio_greater_equal<std::ratio<1,3>,
71 std::ratio<1,3>>::value == 1) );
72 VERIFY( (std::ratio_greater_equal<std::ratio<1,3>,
73 std::ratio<-1,3>>::value == 1) );
74
75 VERIFY( (std::ratio_greater_equal<std::ratio<-1,3>,
76 std::ratio<1,3>>::value == 0) );
77 VERIFY( (std::ratio_greater_equal<std::ratio<1,4>,
78 std::ratio<1,3>>::value == 0) );
79 }
80
main()81 int main()
82 {
83 test01();
84 test02();
85 return 0;
86 }
87