1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // test ratio_less
11
12 #include <ratio>
13
14 #include "test_macros.h"
15
16 template <class Rat1, class Rat2, bool result>
test()17 void test()
18 {
19 static_assert((result == std::ratio_less<Rat1, Rat2>::value), "");
20 #if TEST_STD_VER > 14
21 static_assert((result == std::ratio_less_v<Rat1, Rat2>), "");
22 #endif
23 }
24
main()25 int main()
26 {
27 {
28 typedef std::ratio<1, 1> R1;
29 typedef std::ratio<1, 1> R2;
30 test<R1, R2, false>();
31 }
32 {
33 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
34 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
35 test<R1, R2, false>();
36 }
37 {
38 typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
39 typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
40 test<R1, R2, false>();
41 }
42 {
43 typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
44 typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
45 test<R1, R2, false>();
46 }
47 {
48 typedef std::ratio<1, 1> R1;
49 typedef std::ratio<1, -1> R2;
50 test<R1, R2, false>();
51 }
52 {
53 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
54 typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
55 test<R1, R2, false>();
56 }
57 {
58 typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
59 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
60 test<R1, R2, true>();
61 }
62 {
63 typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
64 typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
65 test<R1, R2, false>();
66 }
67 {
68 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1;
69 typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2;
70 test<R1, R2, true>();
71 }
72 {
73 typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
74 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2;
75 test<R1, R2, false>();
76 }
77 {
78 typedef std::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
79 typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2;
80 test<R1, R2, true>();
81 }
82 {
83 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1;
84 typedef std::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2;
85 test<R1, R2, true>();
86 }
87 {
88 typedef std::ratio<641981, 1339063> R1;
89 typedef std::ratio<1291640, 2694141LL> R2;
90 test<R1, R2, false>();
91 }
92 {
93 typedef std::ratio<1291640, 2694141LL> R1;
94 typedef std::ratio<641981, 1339063> R2;
95 test<R1, R2, true>();
96 }
97 }
98