diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
commit | 1a78a62555be32868418fe52f8e330c9d0f95d5a (patch) | |
tree | d3765a80e7d3b9640ec2e930743630cd6b9fce2b /libs/chrono/test/traits | |
download | boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2 boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip |
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'libs/chrono/test/traits')
4 files changed, 172 insertions, 0 deletions
diff --git a/libs/chrono/test/traits/common_type_duration_pass.cpp b/libs/chrono/test/traits/common_type_duration_pass.cpp new file mode 100644 index 0000000000..16911d90a2 --- /dev/null +++ b/libs/chrono/test/traits/common_type_duration_pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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 <boost/chrono/chrono.hpp> +#include <boost/type_traits/is_same.hpp> + +#if !defined(BOOST_NO_STATIC_ASSERT) +#define NOTHING "" +#endif + +template <class D1, class D2, class De> +void +test() +{ + typedef typename boost::common_type<D1, D2>::type Dc; + BOOST_CHRONO_STATIC_ASSERT((boost::is_same<Dc, De>::value), NOTHING, (D1, D2, Dc, De)); +} + +void testall() +{ + test<boost::chrono::duration<int, boost::ratio<1, 100> >, + boost::chrono::duration<long, boost::ratio<1, 1000> >, + boost::chrono::duration<long, boost::ratio<1, 1000> > >(); + test<boost::chrono::duration<long, boost::ratio<1, 100> >, + boost::chrono::duration<int, boost::ratio<1, 1000> >, + boost::chrono::duration<long, boost::ratio<1, 1000> > >(); + test<boost::chrono::duration<char, boost::ratio<1, 30> >, + boost::chrono::duration<short, boost::ratio<1, 1000> >, + boost::chrono::duration<int, boost::ratio<1, 3000> > >(); + test<boost::chrono::duration<double, boost::ratio<21, 1> >, + boost::chrono::duration<short, boost::ratio<15, 1> >, + boost::chrono::duration<double, boost::ratio<3, 1> > >(); +} diff --git a/libs/chrono/test/traits/common_type_time_point_pass.cpp b/libs/chrono/test/traits/common_type_time_point_pass.cpp new file mode 100644 index 0000000000..e09a8d982f --- /dev/null +++ b/libs/chrono/test/traits/common_type_time_point_pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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 <boost/chrono/chrono.hpp> +#include <boost/type_traits.hpp> + +#if !defined(BOOST_NO_STATIC_ASSERT) +#define NOTHING "" +#endif + +template <class D1, class D2, class De> +void +test() +{ + typedef boost::chrono::system_clock C; + typedef boost::chrono::time_point<C, D1> T1; + typedef boost::chrono::time_point<C, D2> T2; + typedef boost::chrono::time_point<C, De> Te; + typedef typename boost::common_type<T1, T2>::type Tc; + BOOST_CHRONO_STATIC_ASSERT((boost::is_same<Tc, Te>::value), NOTHING, (T1, T2, Tc, Te)); +} + +void testall() +{ + test<boost::chrono::duration<int, boost::ratio<1, 100> >, + boost::chrono::duration<long, boost::ratio<1, 1000> >, + boost::chrono::duration<long, boost::ratio<1, 1000> > >(); + test<boost::chrono::duration<long, boost::ratio<1, 100> >, + boost::chrono::duration<int, boost::ratio<1, 1000> >, + boost::chrono::duration<long, boost::ratio<1, 1000> > >(); + test<boost::chrono::duration<char, boost::ratio<1, 30> >, + boost::chrono::duration<short, boost::ratio<1, 1000> >, + boost::chrono::duration<int, boost::ratio<1, 3000> > >(); + test<boost::chrono::duration<double, boost::ratio<21, 1> >, + boost::chrono::duration<short, boost::ratio<15, 1> >, + boost::chrono::duration<double, boost::ratio<3, 1> > >(); +} diff --git a/libs/chrono/test/traits/duration_values_pass.cpp b/libs/chrono/test/traits/duration_values_pass.cpp new file mode 100644 index 0000000000..9c2879419e --- /dev/null +++ b/libs/chrono/test/traits/duration_values_pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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 <boost/chrono/chrono.hpp> +#include <boost/type_traits.hpp> +#include <limits> +#include <boost/detail/lightweight_test.hpp> + +#include <libs/chrono/test/rep.h> + +int main() +{ + BOOST_TEST((boost::chrono::duration_values<int>::min)() == + (std::numeric_limits<int>::min)()); + BOOST_TEST((boost::chrono::duration_values<double>::min)() == + -(std::numeric_limits<double>::max)()); + BOOST_TEST((boost::chrono::duration_values<Rep>::min)() == + (std::numeric_limits<Rep>::min)()); + + BOOST_TEST((boost::chrono::duration_values<int>::max)() == + (std::numeric_limits<int>::max)()); + BOOST_TEST((boost::chrono::duration_values<double>::max)() == + (std::numeric_limits<double>::max)()); + BOOST_TEST((boost::chrono::duration_values<Rep>::max)() == + (std::numeric_limits<Rep>::max)()); + + BOOST_TEST(boost::chrono::duration_values<int>::zero() == 0); + BOOST_TEST(boost::chrono::duration_values<Rep>::zero() == 0); + + return boost::report_errors(); +} diff --git a/libs/chrono/test/traits/treat_as_floating_point_pass.cpp b/libs/chrono/test/traits/treat_as_floating_point_pass.cpp new file mode 100644 index 0000000000..1780faafde --- /dev/null +++ b/libs/chrono/test/traits/treat_as_floating_point_pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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 <boost/chrono/chrono.hpp> +#include <boost/type_traits.hpp> + +#if !defined(BOOST_NO_STATIC_ASSERT) +#define NOTHING "" +#endif + +template <class T> +void +test() +{ + BOOST_CHRONO_STATIC_ASSERT((boost::is_base_of<boost::is_floating_point<T>, + boost::chrono::treat_as_floating_point<T> >::value), NOTHING, ()); +} + +struct A {}; + +void testall() +{ + test<int>(); + test<unsigned>(); + test<char>(); + test<bool>(); + test<float>(); + test<double>(); + test<long double>(); + test<A>(); +} |