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_equal
10
11#include <ratio>
12
13#include "test_macros.h"
14
15template <class Rat1, class Rat2, bool result>
16void test()
17{
18 static_assert((result == std::ratio_less_equal<Rat1, Rat2>::value), "");
19#if TEST_STD_VER > 14
20 static_assert((result == std::ratio_less_equal_v<Rat1, Rat2>), "");
21#endif
22}
23
24int main(int, char**)
25{
26 {
27 typedef std::ratio<1, 1> R1;
28 typedef std::ratio<1, 1> R2;
29 test<R1, R2, true>();
30 }
31 {
32 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
33 typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
34 test<R1, R2, true>();
35 }
36 {
37 typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
38 typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
39 test<R1, R2, true>();
40 }
41 {
42 typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
43 typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
44 test<R1, R2, true>();
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 return 0;
68}
69

source code of libcxx/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp