1*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
2*4684ddb6SLionel Sambuc //
3*4684ddb6SLionel Sambuc //                     The LLVM Compiler Infrastructure
4*4684ddb6SLionel Sambuc //
5*4684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6*4684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7*4684ddb6SLionel Sambuc //
8*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
9*4684ddb6SLionel Sambuc 
10*4684ddb6SLionel Sambuc // test ratio_add
11*4684ddb6SLionel Sambuc 
12*4684ddb6SLionel Sambuc #include <ratio>
13*4684ddb6SLionel Sambuc 
main()14*4684ddb6SLionel Sambuc int main()
15*4684ddb6SLionel Sambuc {
16*4684ddb6SLionel Sambuc     {
17*4684ddb6SLionel Sambuc     typedef std::ratio<1, 1> R1;
18*4684ddb6SLionel Sambuc     typedef std::ratio<1, 1> R2;
19*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
20*4684ddb6SLionel Sambuc     static_assert(R::num == 2 && R::den == 1, "");
21*4684ddb6SLionel Sambuc     }
22*4684ddb6SLionel Sambuc     {
23*4684ddb6SLionel Sambuc     typedef std::ratio<1, 2> R1;
24*4684ddb6SLionel Sambuc     typedef std::ratio<1, 1> R2;
25*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
26*4684ddb6SLionel Sambuc     static_assert(R::num == 3 && R::den == 2, "");
27*4684ddb6SLionel Sambuc     }
28*4684ddb6SLionel Sambuc     {
29*4684ddb6SLionel Sambuc     typedef std::ratio<-1, 2> R1;
30*4684ddb6SLionel Sambuc     typedef std::ratio<1, 1> R2;
31*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
32*4684ddb6SLionel Sambuc     static_assert(R::num == 1 && R::den == 2, "");
33*4684ddb6SLionel Sambuc     }
34*4684ddb6SLionel Sambuc     {
35*4684ddb6SLionel Sambuc     typedef std::ratio<1, -2> R1;
36*4684ddb6SLionel Sambuc     typedef std::ratio<1, 1> R2;
37*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
38*4684ddb6SLionel Sambuc     static_assert(R::num == 1 && R::den == 2, "");
39*4684ddb6SLionel Sambuc     }
40*4684ddb6SLionel Sambuc     {
41*4684ddb6SLionel Sambuc     typedef std::ratio<1, 2> R1;
42*4684ddb6SLionel Sambuc     typedef std::ratio<-1, 1> R2;
43*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
44*4684ddb6SLionel Sambuc     static_assert(R::num == -1 && R::den == 2, "");
45*4684ddb6SLionel Sambuc     }
46*4684ddb6SLionel Sambuc     {
47*4684ddb6SLionel Sambuc     typedef std::ratio<1, 2> R1;
48*4684ddb6SLionel Sambuc     typedef std::ratio<1, -1> R2;
49*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
50*4684ddb6SLionel Sambuc     static_assert(R::num == -1 && R::den == 2, "");
51*4684ddb6SLionel Sambuc     }
52*4684ddb6SLionel Sambuc     {
53*4684ddb6SLionel Sambuc     typedef std::ratio<56987354, 467584654> R1;
54*4684ddb6SLionel Sambuc     typedef std::ratio<544668, 22145> R2;
55*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
56*4684ddb6SLionel Sambuc     static_assert(R::num == 127970191639601LL && R::den == 5177331081415LL, "");
57*4684ddb6SLionel Sambuc     }
58*4684ddb6SLionel Sambuc     {
59*4684ddb6SLionel Sambuc     typedef std::ratio<0> R1;
60*4684ddb6SLionel Sambuc     typedef std::ratio<0> R2;
61*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
62*4684ddb6SLionel Sambuc     static_assert(R::num == 0 && R::den == 1, "");
63*4684ddb6SLionel Sambuc     }
64*4684ddb6SLionel Sambuc     {
65*4684ddb6SLionel Sambuc     typedef std::ratio<1> R1;
66*4684ddb6SLionel Sambuc     typedef std::ratio<0> R2;
67*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
68*4684ddb6SLionel Sambuc     static_assert(R::num == 1 && R::den == 1, "");
69*4684ddb6SLionel Sambuc     }
70*4684ddb6SLionel Sambuc     {
71*4684ddb6SLionel Sambuc     typedef std::ratio<0> R1;
72*4684ddb6SLionel Sambuc     typedef std::ratio<1> R2;
73*4684ddb6SLionel Sambuc     typedef std::ratio_add<R1, R2>::type R;
74*4684ddb6SLionel Sambuc     static_assert(R::num == 1 && R::den == 1, "");
75*4684ddb6SLionel Sambuc     }
76*4684ddb6SLionel Sambuc }
77