//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // Adaptation to Boost of the libcxx // Copyright 2010 Vicente J. Botet Escriba // Distributed under the Boost Software License, Version 1.0. // See http://www.boost.org/LICENSE_1_0.txt #include #include #include template void check_default() { D d; BOOST_TEST(d.count() == typename D::rep()); } template void check_from_rep(R r) { D d(r); BOOST_TEST(d.count() == r); } int main() { // exact conversions allowed for integral reps { boost::chrono::milliseconds ms(1); boost::chrono::microseconds us = ms; BOOST_TEST(us.count() == 1000); } // inexact conversions allowed for floating point reps { boost::chrono::duration us(1); boost::chrono::duration ms = us; BOOST_TEST(ms.count() == 1./1000); } // Convert int to float { boost::chrono::duration i(3); boost::chrono::duration d = i; BOOST_TEST(d.count() == 3); } // default constructor { check_default >(); } // constructor from rep { check_from_rep >(5); check_from_rep > >(5); check_from_rep > >(Rep(3)); check_from_rep > >(5.5); } // constructor from other rep { boost::chrono::duration d(5); BOOST_TEST(d.count() == 5); return boost::report_errors(); } return boost::report_errors(); }