1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // Adaptation to Boost of the libcxx
10 // Copyright 2010 Vicente J. Botet Escriba
11 // Distributed under the Boost Software License, Version 1.0.
12 // See http://www.boost.org/LICENSE_1_0.txt
13
14 // test ratio_power
15
16 #define BOOST_RATIO_EXTENSIONS
17 #include <boost/ratio/ratio.hpp>
18
19 #if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
20 #define NOTHING ""
21 #endif
22
test()23 void test()
24 {
25 {
26 typedef boost::ratio<1, 2> R1;
27 typedef boost::ratio_power<R1, 1> R;
28 BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
29 }
30 {
31 typedef boost::ratio<1, 2> R1;
32 typedef boost::ratio_power<R1, -1> R;
33 BOOST_RATIO_STATIC_ASSERT(R::num == 2 && R::den == 1, NOTHING, ());
34 }
35 {
36 typedef boost::ratio<1, 2> R1;
37 typedef boost::ratio_power<R1, 0> R;
38 BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
39 }
40 {
41 typedef boost::ratio<-1, 2> R1;
42 typedef boost::ratio_power<R1, 2> R;
43 BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 4, NOTHING, ());
44 }
45 {
46 typedef boost::ratio<1, -2> R1;
47 typedef boost::ratio_power<R1, 2> R;
48 BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 4, NOTHING, ());
49 }
50 {
51 typedef boost::ratio<2, 3> R1;
52 typedef boost::ratio_power<R1, 2> R;
53 BOOST_RATIO_STATIC_ASSERT(R::num == 4 && R::den == 9, NOTHING, ());
54 }
55 {
56 typedef boost::ratio<2, 3> R1;
57 typedef boost::ratio_power<R1, -2> R;
58 BOOST_RATIO_STATIC_ASSERT(R::num == 9 && R::den == 4, NOTHING, ());
59 }
60 }
61