]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / ratio / comparisons / comp1.cc
1 // { dg-do run { target c++11 } }
2 // { dg-require-cstdint "" }
3
4 // Copyright (C) 2008-2018 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
25 test01()
26 {
27 VERIFY(( std::ratio_equal<std::ratio<2,6>, std::ratio<1,3>>::value == 1 ));
28 VERIFY(( std::ratio_equal<std::ratio<2,6>, std::ratio<1,4>>::value == 0 ));
29
30 VERIFY( (std::ratio_not_equal<std::ratio<2,6>,
31 std::ratio<1,3>>::value == 0) );
32 VERIFY( (std::ratio_not_equal<std::ratio<2,6>,
33 std::ratio<1,4>>::value == 1) );
34 }
35
36 void
37 test02()
38 {
39 VERIFY( (std::ratio_less<std::ratio<1,4>, std::ratio<1,3>>::value == 1) );
40 VERIFY( (std::ratio_less<std::ratio<-1,3>, std::ratio<1,3>>::value == 1) );
41
42 VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<1,4>>::value == 0) );
43 VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<-1,3>>::value == 0) );
44
45 VERIFY( (std::ratio_less<std::ratio<-1,3>, std::ratio<-1,4>>::value == 1) );
46 VERIFY( (std::ratio_less<std::ratio<0,4>, std::ratio<0,3>>::value == 0) );
47 VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<0,3>>::value == 0) );
48 VERIFY( (std::ratio_less<std::ratio<0,3>, std::ratio<-1,4>>::value == 0) );
49
50 VERIFY( (std::ratio_less_equal<std::ratio<-1,3>,
51 std::ratio<-1,3>>::value == 1) );
52 VERIFY( ( std::ratio_less_equal<std::ratio<1,4>,
53 std::ratio<1,3>>::value == 1) );
54
55 VERIFY( (std::ratio_less_equal<std::ratio<1,4>,
56 std::ratio<-1,3>>::value == 0) );
57 VERIFY( (std::ratio_less_equal<std::ratio<1,3>,
58 std::ratio<-1,3>>::value == 0) );
59
60 VERIFY( (std::ratio_greater<std::ratio<1,3>, std::ratio<1,4>>::value == 1) );
61 VERIFY( (std::ratio_greater<std::ratio<1,3>, std::ratio<-1,3>>::value == 1) );
62
63 VERIFY( (std::ratio_greater<std::ratio<1,4>, std::ratio<1,3>>::value == 0) );
64 VERIFY( (std::ratio_greater<std::ratio<-1,3>, std::ratio<1,3>>::value == 0) );
65
66 VERIFY( (std::ratio_greater_equal<std::ratio<1,3>,
67 std::ratio<1,3>>::value == 1) );
68 VERIFY( (std::ratio_greater_equal<std::ratio<1,3>,
69 std::ratio<-1,3>>::value == 1) );
70
71 VERIFY( (std::ratio_greater_equal<std::ratio<-1,3>,
72 std::ratio<1,3>>::value == 0) );
73 VERIFY( (std::ratio_greater_equal<std::ratio<1,4>,
74 std::ratio<1,3>>::value == 0) );
75 }
76
77 int main()
78 {
79 test01();
80 test02();
81 return 0;
82 }