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