ratio.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===// 2// 3// ��������������������The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// test ratio: The static data members num and den shall have thcommon 11// divisor of the absolute values of N and D: 12 13#include <ratio> 14 15template <long long N, long long D, long long eN, long long eD> 16void test() 17{ 18 static_assert((std::ratio<N, D>::num == eN), ""); 19 static_assert((std::ratio<N, D>::den == eD), ""); 20} 21 22int 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