op_divide_duration.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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// <chrono> 11 12// duration 13 14// template <class Rep1, class Period1, class Rep2, class Period2> 15// typename common_type<Rep1, Rep2>::type 16// operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 17 18#include <chrono> 19#include <cassert> 20 21int main() 22{ 23 { 24 std::chrono::nanoseconds ns1(15); 25 std::chrono::nanoseconds ns2(5); 26 assert(ns1 / ns2 == 3); 27 } 28 { 29 std::chrono::microseconds us1(15); 30 std::chrono::nanoseconds ns2(5); 31 assert(us1 / ns2 == 3000); 32 } 33 { 34 std::chrono::duration<int, std::ratio<2, 3> > s1(30); 35 std::chrono::duration<int, std::ratio<3, 5> > s2(5); 36 assert(s1 / s2 == 6); 37 } 38 { 39 std::chrono::duration<int, std::ratio<2, 3> > s1(30); 40 std::chrono::duration<double, std::ratio<3, 5> > s2(5); 41 assert(s1 / s2 == 20./3); 42 } 43} 44