| 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: The static data members num and den shall have the common |
| 10 |
// divisor of the absolute values of N and D: |
| 11 |
|
| 12 |
#include <ratio> |
| 13 |
|
| 14 |
#include "test_macros.h" |
| 15 |
|
| 16 |
template <long long N, long long D, long long eN, long long eD> |
| 17 |
void test() |
| 18 |
{ |
| 19 |
static_assert((std::ratio<N, D>::num == eN), ""); |
| 20 |
static_assert((std::ratio<N, D>::den == eD), ""); |
| 21 |
} |
| 22 |
|
| 23 |
int main(int, char**) |
| 24 |
{ |
| 25 |
test<1, 1, 1, 1>(); |
| 26 |
test<1, 10, 1, 10>(); |
| 27 |
test<10, 10, 1, 1>(); |
| 28 |
test<10, 1, 10, 1>(); |
| 29 |
test<12, 4, 3, 1>(); |
| 30 |
test<12, -4, -3, 1>(); |
| 31 |
test<-12, 4, -3, 1>(); |
| 32 |
test<-12, -4, 3, 1>(); |
| 33 |
test<4, 12, 1, 3>(); |
| 34 |
test<4, -12, -1, 3>(); |
| 35 |
test<-4, 12, -1, 3>(); |
| 36 |
test<-4, -12, 1, 3>(); |
| 37 |
test<222, 333, 2, 3>(); |
| 38 |
test<222, -333, -2, 3>(); |
| 39 |
test<-222, 333, -2, 3>(); |
| 40 |
test<-222, -333, 2, 3>(); |
| 41 |
test<0x7FFFFFFFFFFFFFFFLL, 127, 72624976668147841LL, 1>(); |
| 42 |
test<-0x7FFFFFFFFFFFFFFFLL, 127, -72624976668147841LL, 1>(); |
| 43 |
test<0x7FFFFFFFFFFFFFFFLL, -127, -72624976668147841LL, 1>(); |
| 44 |
test<-0x7FFFFFFFFFFFFFFFLL, -127, 72624976668147841LL, 1>(); |
| 45 |
|
| 46 |
return 0; |
| 47 |
} |