1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // test ratio_less |
10 | |
11 | #include <ratio> |
12 | |
13 | #include "test_macros.h" |
14 | |
15 | template <class Rat1, class Rat2, bool result> |
16 | void test() |
17 | { |
18 | static_assert((result == std::ratio_less<Rat1, Rat2>::value), "" ); |
19 | #if TEST_STD_VER > 14 |
20 | static_assert((result == std::ratio_less_v<Rat1, Rat2>), "" ); |
21 | #endif |
22 | } |
23 | |
24 | int main(int, char**) |
25 | { |
26 | { |
27 | typedef std::ratio<1, 1> R1; |
28 | typedef std::ratio<1, 1> R2; |
29 | test<R1, R2, false>(); |
30 | } |
31 | { |
32 | typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; |
33 | typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; |
34 | test<R1, R2, false>(); |
35 | } |
36 | { |
37 | typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; |
38 | typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; |
39 | test<R1, R2, false>(); |
40 | } |
41 | { |
42 | typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; |
43 | typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; |
44 | test<R1, R2, false>(); |
45 | } |
46 | { |
47 | typedef std::ratio<1, 1> R1; |
48 | typedef std::ratio<1, -1> R2; |
49 | test<R1, R2, false>(); |
50 | } |
51 | { |
52 | typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; |
53 | typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; |
54 | test<R1, R2, false>(); |
55 | } |
56 | { |
57 | typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; |
58 | typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; |
59 | test<R1, R2, true>(); |
60 | } |
61 | { |
62 | typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; |
63 | typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; |
64 | test<R1, R2, false>(); |
65 | } |
66 | { |
67 | typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1; |
68 | typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2; |
69 | test<R1, R2, true>(); |
70 | } |
71 | { |
72 | typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1; |
73 | typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2; |
74 | test<R1, R2, false>(); |
75 | } |
76 | { |
77 | typedef std::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1; |
78 | typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2; |
79 | test<R1, R2, true>(); |
80 | } |
81 | { |
82 | typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1; |
83 | typedef std::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2; |
84 | test<R1, R2, true>(); |
85 | } |
86 | { |
87 | typedef std::ratio<641981, 1339063> R1; |
88 | typedef std::ratio<1291640, 2694141LL> R2; |
89 | test<R1, R2, false>(); |
90 | } |
91 | { |
92 | typedef std::ratio<1291640, 2694141LL> R1; |
93 | typedef std::ratio<641981, 1339063> R2; |
94 | test<R1, R2, true>(); |
95 | } |
96 | |
97 | return 0; |
98 | } |
99 | |