| 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_multiply |
| 10 | |
| 11 | #include <ratio> |
| 12 | |
| 13 | #include "test_macros.h" |
| 14 | |
| 15 | int main(int, char**) |
| 16 | { |
| 17 | { |
| 18 | typedef std::ratio<1, 1> R1; |
| 19 | typedef std::ratio<1, 1> R2; |
| 20 | typedef std::ratio_multiply<R1, R2>::type R; |
| 21 | static_assert(R::num == 1 && R::den == 1, "" ); |
| 22 | } |
| 23 | { |
| 24 | typedef std::ratio<1, 2> R1; |
| 25 | typedef std::ratio<1, 1> R2; |
| 26 | typedef std::ratio_multiply<R1, R2>::type R; |
| 27 | static_assert(R::num == 1 && R::den == 2, "" ); |
| 28 | } |
| 29 | { |
| 30 | typedef std::ratio<-1, 2> R1; |
| 31 | typedef std::ratio<1, 1> R2; |
| 32 | typedef std::ratio_multiply<R1, R2>::type R; |
| 33 | static_assert(R::num == -1 && R::den == 2, "" ); |
| 34 | } |
| 35 | { |
| 36 | typedef std::ratio<1, -2> R1; |
| 37 | typedef std::ratio<1, 1> R2; |
| 38 | typedef std::ratio_multiply<R1, R2>::type R; |
| 39 | static_assert(R::num == -1 && R::den == 2, "" ); |
| 40 | } |
| 41 | { |
| 42 | typedef std::ratio<1, 2> R1; |
| 43 | typedef std::ratio<-1, 1> R2; |
| 44 | typedef std::ratio_multiply<R1, R2>::type R; |
| 45 | static_assert(R::num == -1 && R::den == 2, "" ); |
| 46 | } |
| 47 | { |
| 48 | typedef std::ratio<1, 2> R1; |
| 49 | typedef std::ratio<1, -1> R2; |
| 50 | typedef std::ratio_multiply<R1, R2>::type R; |
| 51 | static_assert(R::num == -1 && R::den == 2, "" ); |
| 52 | } |
| 53 | { |
| 54 | typedef std::ratio<56987354, 467584654> R1; |
| 55 | typedef std::ratio<544668, 22145> R2; |
| 56 | typedef std::ratio_multiply<R1, R2>::type R; |
| 57 | static_assert(R::num == 15519594064236LL && R::den == 5177331081415LL, "" ); |
| 58 | } |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |