From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/chrono/test/Jamfile.v2 | 465 +++++++++++++++++++++ src/boost/libs/chrono/test/another_obj.cpp | 19 + src/boost/libs/chrono/test/clock.h | 30 ++ src/boost/libs/chrono/test/clock/clock_pass.cpp | 201 +++++++++ src/boost/libs/chrono/test/clock/errored_clock.hpp | 62 +++ .../libs/chrono/test/duration/arithmetic_pass.cpp | 350 ++++++++++++++++ .../libs/chrono/test/duration/comparisons_pass.cpp | 222 ++++++++++ .../duration/cons/convert_float_to_int_fail.cpp | 22 + .../test/duration/cons/convert_inexact_fail.cpp | 22 + .../duration/cons/implicit_constructot_fail.cpp | 23 + .../cons/non_implicit_convertible_rep_fail.cpp | 23 + .../treat_as_floating_point_Rep2_true_fail.cpp | 21 + .../libs/chrono/test/duration/constructor_pass.cpp | 134 ++++++ .../chrono/test/duration/default_ratio_pass.cpp | 29 ++ .../test/duration/duration_cast_int_fail.cpp | 21 + .../chrono/test/duration/duration_cast_pass.cpp | 59 +++ .../test/duration/duration_duration_fail.cpp | 24 ++ .../chrono/test/duration/duration_values_pass.cpp | 76 ++++ .../test/duration/nonmember/divide_rep2_fail.cpp | 22 + .../test/duration/nonmember/modulus_rep2_fail.cpp | 22 + .../duration/nonmember/times_rep2_lhs_fail.cpp | 22 + .../duration/nonmember/times_rep2_rhs_fail.cpp | 22 + .../chrono/test/duration/positive_num_fail.cpp | 23 + .../libs/chrono/test/duration/ratio_alias_pass.cpp | 29 ++ src/boost/libs/chrono/test/duration/ratio_fail.cpp | 23 + .../libs/chrono/test/duration/rounding_pass.cpp | 105 +++++ .../libs/chrono/test/duration/typedefs_pass.cpp | 42 ++ src/boost/libs/chrono/test/duration/types_pass.cpp | 28 ++ src/boost/libs/chrono/test/intmax_c.cpp | 19 + src/boost/libs/chrono/test/io/duration_input.cpp | 124 ++++++ src/boost/libs/chrono/test/io/duration_output.cpp | 114 +++++ src/boost/libs/chrono/test/io/time_point_input.cpp | 238 +++++++++++ .../libs/chrono/test/io/time_point_output.cpp | 317 ++++++++++++++ src/boost/libs/chrono/test/one_obj.cpp | 23 + src/boost/libs/chrono/test/rep.h | 67 +++ src/boost/libs/chrono/test/run_timer_test.cpp | 226 ++++++++++ src/boost/libs/chrono/test/test_10631.cpp | 61 +++ src/boost/libs/chrono/test/test_10778.cpp | 19 + src/boost/libs/chrono/test/test_11006.cpp | 21 + src/boost/libs/chrono/test/test_11012.cpp | 27 ++ src/boost/libs/chrono/test/test_12176.cpp | 11 + src/boost/libs/chrono/test/test_7868.cpp | 81 ++++ src/boost/libs/chrono/test/test_9337.cpp | 27 ++ .../chrono/test/time_point/arithmetic_ext_pass.cpp | 70 ++++ .../chrono/test/time_point/arithmetic_pass.cpp | 151 +++++++ .../test/time_point/comparisons/equal_fail.cpp | 32 ++ .../test/time_point/comparisons/less_fail.cpp | 32 ++ .../chrono/test/time_point/comparisons_pass.cpp | 146 +++++++ .../chrono/test/time_point/cons/implicit_fail.cpp | 23 + .../non_implicit_convertible_duration_fail.cpp | 27 ++ .../chrono/test/time_point/constructor_pass.cpp | 80 ++++ .../test/time_point/default_duration.pass.cpp | 24 ++ .../test/time_point/default_duration_pass.cpp | 24 ++ .../libs/chrono/test/time_point/duration.fail.cpp | 22 + .../libs/chrono/test/time_point/min_max_pass.cpp | 34 ++ .../chrono/test/time_point/not_duration_fail.cpp | 22 + .../test/time_point/time_point_cast_int_fail.cpp | 24 ++ .../test/time_point/time_point_cast_pass.cpp | 67 +++ .../test/traits/common_type_duration_pass.cpp | 43 ++ .../test/traits/common_type_time_point_pass.cpp | 47 +++ .../chrono/test/traits/duration_values_pass.cpp | 41 ++ .../test/traits/treat_as_floating_point_pass.cpp | 41 ++ src/boost/libs/chrono/test/win32_test.cpp | 149 +++++++ 63 files changed, 4615 insertions(+) create mode 100644 src/boost/libs/chrono/test/Jamfile.v2 create mode 100644 src/boost/libs/chrono/test/another_obj.cpp create mode 100644 src/boost/libs/chrono/test/clock.h create mode 100644 src/boost/libs/chrono/test/clock/clock_pass.cpp create mode 100644 src/boost/libs/chrono/test/clock/errored_clock.hpp create mode 100644 src/boost/libs/chrono/test/duration/arithmetic_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/comparisons_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/cons/convert_float_to_int_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/cons/convert_inexact_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/cons/implicit_constructot_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/cons/non_implicit_convertible_rep_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/cons/treat_as_floating_point_Rep2_true_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/constructor_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/default_ratio_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/duration_cast_int_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/duration_cast_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/duration_duration_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/duration_values_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/nonmember/divide_rep2_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/nonmember/modulus_rep2_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/nonmember/times_rep2_lhs_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/nonmember/times_rep2_rhs_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/positive_num_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/ratio_alias_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/ratio_fail.cpp create mode 100644 src/boost/libs/chrono/test/duration/rounding_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/typedefs_pass.cpp create mode 100644 src/boost/libs/chrono/test/duration/types_pass.cpp create mode 100644 src/boost/libs/chrono/test/intmax_c.cpp create mode 100644 src/boost/libs/chrono/test/io/duration_input.cpp create mode 100644 src/boost/libs/chrono/test/io/duration_output.cpp create mode 100644 src/boost/libs/chrono/test/io/time_point_input.cpp create mode 100644 src/boost/libs/chrono/test/io/time_point_output.cpp create mode 100644 src/boost/libs/chrono/test/one_obj.cpp create mode 100644 src/boost/libs/chrono/test/rep.h create mode 100644 src/boost/libs/chrono/test/run_timer_test.cpp create mode 100644 src/boost/libs/chrono/test/test_10631.cpp create mode 100644 src/boost/libs/chrono/test/test_10778.cpp create mode 100644 src/boost/libs/chrono/test/test_11006.cpp create mode 100644 src/boost/libs/chrono/test/test_11012.cpp create mode 100644 src/boost/libs/chrono/test/test_12176.cpp create mode 100644 src/boost/libs/chrono/test/test_7868.cpp create mode 100644 src/boost/libs/chrono/test/test_9337.cpp create mode 100644 src/boost/libs/chrono/test/time_point/arithmetic_ext_pass.cpp create mode 100644 src/boost/libs/chrono/test/time_point/arithmetic_pass.cpp create mode 100644 src/boost/libs/chrono/test/time_point/comparisons/equal_fail.cpp create mode 100644 src/boost/libs/chrono/test/time_point/comparisons/less_fail.cpp create mode 100644 src/boost/libs/chrono/test/time_point/comparisons_pass.cpp create mode 100644 src/boost/libs/chrono/test/time_point/cons/implicit_fail.cpp create mode 100644 src/boost/libs/chrono/test/time_point/cons/non_implicit_convertible_duration_fail.cpp create mode 100644 src/boost/libs/chrono/test/time_point/constructor_pass.cpp create mode 100644 src/boost/libs/chrono/test/time_point/default_duration.pass.cpp create mode 100644 src/boost/libs/chrono/test/time_point/default_duration_pass.cpp create mode 100644 src/boost/libs/chrono/test/time_point/duration.fail.cpp create mode 100644 src/boost/libs/chrono/test/time_point/min_max_pass.cpp create mode 100644 src/boost/libs/chrono/test/time_point/not_duration_fail.cpp create mode 100644 src/boost/libs/chrono/test/time_point/time_point_cast_int_fail.cpp create mode 100644 src/boost/libs/chrono/test/time_point/time_point_cast_pass.cpp create mode 100644 src/boost/libs/chrono/test/traits/common_type_duration_pass.cpp create mode 100644 src/boost/libs/chrono/test/traits/common_type_time_point_pass.cpp create mode 100644 src/boost/libs/chrono/test/traits/duration_values_pass.cpp create mode 100644 src/boost/libs/chrono/test/traits/treat_as_floating_point_pass.cpp create mode 100644 src/boost/libs/chrono/test/win32_test.cpp (limited to 'src/boost/libs/chrono/test') diff --git a/src/boost/libs/chrono/test/Jamfile.v2 b/src/boost/libs/chrono/test/Jamfile.v2 new file mode 100644 index 00000000..7565d27b --- /dev/null +++ b/src/boost/libs/chrono/test/Jamfile.v2 @@ -0,0 +1,465 @@ +# Boost Chrono Library test Jamfile + +# Copyright Beman Dawes 2008 +# Copyright Vicente J. Botet Escriba 2009-2010 + +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt + +# See library home page at http://www.boost.org/libs/chrono + +import testing ; +import os ; +import feature ; + +project + : requirements + freebsd:"-lrt" + linux:"-lrt -lpthread" + clang/linux:"-lpthread" + pgi:"-lrt" + #single:BOOST_CHRONO_THREAD_DISABLED + msvc:on + BOOST_CHRONO_USES_MPL_ASSERT + #sun:BOOST_COMMON_TYPE_DONT_USE_TYPEOF + #sun:BOOST_TYPEOF_EMULATION + sun:__typeof__=__typeof__ + all + gcc:-Wextra + #gcc:-pedantic + clang:on + gcc:-Wno-long-long + gcc:-Wno-variadic-macros + darwin:-Wextra + darwin:-pedantic + darwin:-Wno-long-long + darwin:-Wno-variadic-macros + #pathscale:-Wextra + pathscale:-Wno-long-long + pathscale:-pedantic + clang:-Wextra + clang:-pedantic + clang:-Wno-long-long + clang:-Wno-variadic-macros + gcc-4.5.0,windows:-Wno-missing-field-initializers + gcc-4.5.0,windows:-fdiagnostics-show-option + msvc:/wd4127 + msvc:/wd4512 +# Note: Some of the remarks from the Intel compiler are disabled +# remark #193: zero used for undefined preprocessing identifier "XXX" +# remark #304: access control not specified ("public" by default) +# remark #383: value copied to temporary, reference to temporary used +# remark #444: destructor for base class "XXX" (declared at line YYY") is not virtual +# remark #593: variable "XXX" was set but never used +# remark #981: operands are evaluated in unspecified order +# remark #1418: external function definition with no prior declaration +# remark #2415: variable "XXX" of static storage duration was declared but never referenced + + intel:-wd193,304,383,444 + intel:-wd593,981 + intel:-wd1418 + intel:-wd2415 + ; + +rule chrono-run ( sources ) +{ + return + [ run $(sources) ../build//boost_chrono + : : + : + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_d ] + #[ run $(sources) ../build//boost_chrono/static + # : : + # : + # : $(sources[1]:B)_s ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_h ] + ; +} + +rule chrono-runXXX ( sources ) +{ + return + [ run $(sources) ../build//boost_chrono + : : + : + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_d ] + #[ run $(sources) ../build//boost_chrono/static + # : : + # : + # : $(sources[1]:B)_s ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_h ] + ; +} + + +rule chrono-v1-v2-run ( sources ) +{ + return + [ run $(sources) ../build//boost_chrono + : : + : + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_d ] + [ run $(sources) ../build//boost_chrono/static + : : + : + : v1_$(sources[1]:B)_s ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_h ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + #BOOST_CHRONO_VERSION=1 + : v1_$(sources[1]:B)_h ] + ; +} + +rule chrono-run2 ( sources : name ) +{ + return + [ run $(sources) ../build//boost_chrono + : : + : + BOOST_CHRONO_VERSION=2 + : $(name)_d ] + #[ run $(sources) ../build//boost_chrono/static + # : : + # : + # : $(name)_s ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(name)_h ] + ; +} + +rule date-run ( sources + ) +{ + return + [ run $(sources) ../build//boost_chrono + : : + : + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_d ] + ; +} + +rule date-run-2 ( sources + : name ) +{ + return + [ run $(sources) ../build//boost_chrono + : : + : + BOOST_CHRONO_VERSION=2 + : $(name)_d ] + ; +} + + +rule chrono-run-mt ( sources ) +{ + return + [ run $(sources) ../build//boost_chrono + : : + : + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_d ] + #[ run $(sources) ../build//boost_chrono/static + # : : + # : + # : $(sources[1]:B)_s ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_h ] + ; +} +rule chrono-run2-mt ( sources * : name ) +{ + return + [ run $(sources) ../build//boost_chrono + : : + : + BOOST_CHRONO_VERSION=2 + : $(name)_d ] + #[ run $(sources) ../build//boost_chrono/static + # : : + # : + # : $(name)_s ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(name)_h ] + ; +} + +rule chrono-run-check ( sources ) +{ + return + [ run $(sources) + : : + : + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_d ] + [ run $(sources) + : : + : + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_s ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_h ] + ; +} + +rule chrono-run-check2 ( sources : name ) +{ + return + [ run $(sources) + : : + : + BOOST_CHRONO_VERSION=2 + : $(name)_d ] + [ run $(sources) + : : + : + BOOST_CHRONO_VERSION=2 + : $(name)_s ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(name)_h ] + ; +} + +rule chrono-run-header ( sources ) +{ + return + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_h ] + ; +} + +rule chrono-v1-v2-run-header ( sources ) +{ + return + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_h ] + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + : v1_$(sources[1]:B)_h ] + ; +} + +rule chrono-run-header2 ( sources : name ) +{ + return + [ run $(sources) + : : + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(name)_h ] + ; +} + +rule chrono-compile ( sources ) +{ + return + [ compile $(sources) + : + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_l ] + [ compile $(sources) + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(sources[1]:B)_h ] + ; +} + +rule chrono-compile2 ( sources : name ) +{ + return + [ compile $(sources) + : + BOOST_CHRONO_VERSION=2 + : $(name)_l ] + [ compile $(sources) + : BOOST_CHRONO_HEADER_ONLY + BOOST_ERROR_CODE_HEADER_ONLY + #BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + BOOST_CHRONO_VERSION=2 + : $(name)_h ] + ; +} + + + test-suite "examples" + : + [ chrono-run-header ../example/cycle_count.cpp ] + [ chrono-run-header ../example/runtime_resolution.cpp ] + [ chrono-run-header ../example/xtime.cpp ] + [ chrono-run-header ../example/saturating.cpp ] + [ chrono-run ../example/min_time_point.cpp ] + [ chrono-run-header ../example/i_dont_like_the_default_duration_behavior.cpp ] + [ chrono-run ../example/simulated_thread_interface_demo.cpp ] + [ chrono-run-header ../example/timeval_demo.cpp ] + [ chrono-run ../example/chrono_unit_test.cpp ] + [ chrono-run-header ../example/explore_limits.cpp ] + [ chrono-run-header ../example/test_duration.cpp ] + [ chrono-run ../example/test_clock.cpp ] + [ chrono-run-header ../example/miscellaneous.cpp ] + [ chrono-run-header ../example/test_special_values.cpp ] + [ chrono-run ../example/manipulate_clock_object.cpp ] + [ chrono-run-mt ../example/test_thread_clock.cpp ] + [ chrono-run-header ../example/rounding.cpp ] + #[ chrono-run ../example/await_keystroke.cpp ] + ; + + test-suite "traits" + : + [ chrono-compile2 traits/common_type_duration_pass.cpp : traits_common_type_duration_p ] + [ chrono-compile2 traits/common_type_time_point_pass.cpp : traits_common_type_time_point_p ] + [ chrono-compile2 traits/treat_as_floating_point_pass.cpp : traits_treat_as_floating_point_p ] + [ chrono-run-header2 traits/duration_values_pass.cpp : traits_duration_values_p ] + ; + + test-suite "duration" + : + [ compile-fail duration/duration_duration_fail.cpp ] + [ compile-fail duration/ratio_fail.cpp ] + [ compile-fail duration/positive_num_fail.cpp ] + [ chrono-compile duration/default_ratio_pass.cpp ] + [ chrono-compile duration/types_pass.cpp ] + [ chrono-compile duration/ratio_alias_pass.cpp ] + [ chrono-compile duration/typedefs_pass.cpp ] + [ chrono-run-header duration/arithmetic_pass.cpp ] + [ chrono-run-header duration/duration_cast_pass.cpp ] + [ compile-fail duration/duration_cast_int_fail.cpp ] + [ chrono-run-header duration/comparisons_pass.cpp ] + [ chrono-run-header duration/constructor_pass.cpp ] + [ compile-fail duration/cons/convert_float_to_int_fail.cpp ] + [ compile-fail duration/cons/convert_inexact_fail.cpp ] + [ compile-fail duration/cons/implicit_constructot_fail.cpp ] + [ compile-fail duration/cons/non_implicit_convertible_rep_fail.cpp ] + [ compile-fail duration/cons/treat_as_floating_point_Rep2_true_fail.cpp ] + [ compile-fail duration/nonmember/divide_rep2_fail.cpp ] + [ compile-fail duration/nonmember/modulus_rep2_fail.cpp ] + [ compile-fail duration/nonmember/times_rep2_lhs_fail.cpp ] + [ compile-fail duration/nonmember/times_rep2_rhs_fail.cpp ] + [ chrono-run-header duration/duration_values_pass.cpp ] + [ chrono-run-header duration/rounding_pass.cpp ] + ; + + test-suite "time_point" + : + [ chrono-compile2 time_point/default_duration_pass.cpp : time_point_default_duration_p ] + [ compile-fail time_point/not_duration_fail.cpp : : time_point_not_duration_f ] + [ chrono-run-header2 time_point/arithmetic_pass.cpp : time_point_arithmetic_p ] + [ chrono-run-header2 time_point/arithmetic_ext_pass.cpp : time_point_arithmetic_ext_p ] + [ chrono-run-header2 time_point/time_point_cast_pass.cpp : time_point_time_point_cast_p ] + [ compile-fail time_point/time_point_cast_int_fail.cpp : : time_point_time_point_cast_int_f ] + [ chrono-run-header2 time_point/comparisons_pass.cpp : time_point_comparisons_p ] + [ compile-fail time_point/comparisons/equal_fail.cpp : : time_point_equal_f ] + [ compile-fail time_point/comparisons/less_fail.cpp : : time_point_less_f ] + [ chrono-run-header2 time_point/constructor_pass.cpp : time_point_constructor_p ] + [ compile-fail time_point/cons/implicit_fail.cpp : : time_point_implicit_f ] + [ compile-fail time_point/cons/non_implicit_convertible_duration_fail.cpp : : time_point_non_implicit_convertible_duration_f ] + [ chrono-run-header2 time_point/min_max_pass.cpp : time_point_min_max_p ] + ; + + test-suite "clock" + : + [ chrono-run2-mt clock/clock_pass.cpp : clock_clock_p ] + [ chrono-run2-mt one_obj.cpp another_obj.cpp : two_obj_p ] + ; + + test-suite "io_ex" + : + [ chrono-v1-v2-run ../example/io_ex1.cpp ] + [ chrono-v1-v2-run-header ../example/io_ex2.cpp ] + [ chrono-v1-v2-run ../example/io_ex3.cpp ] + [ chrono-v1-v2-run ../example/io_ex4.cpp ] + [ chrono-v1-v2-run ../example/io_ex5.cpp ] + [ chrono-v1-v2-run ../example/french.cpp ] + ; + + test-suite "io" + : + [ chrono-v1-v2-run-header io/duration_input.cpp ] + [ chrono-v1-v2-run-header io/duration_output.cpp ] + [ chrono-v1-v2-run-header io/time_point_input.cpp ] + [ chrono-v1-v2-run-header io/time_point_output.cpp ] + [ chrono-run test_7868.cpp ] + [ chrono-run test_11006.cpp ] + [ chrono-run test_11012.cpp ] + [ chrono-runXXX test_12176.cpp ] + ; + + test-suite "win32" + : + [ chrono-run win32_test.cpp ] + ; + + explicit ts_ ; + test-suite ts_ + : + #[ chrono-run test_7868.cpp ] + #[ chrono-run test_9337.cpp ] + #[ chrono-run test_10778.cpp ] + [ chrono-run test_10631.cpp ] + ; + diff --git a/src/boost/libs/chrono/test/another_obj.cpp b/src/boost/libs/chrono/test/another_obj.cpp new file mode 100644 index 00000000..8ebf6772 --- /dev/null +++ b/src/boost/libs/chrono/test/another_obj.cpp @@ -0,0 +1,19 @@ +// boost win32_test.cpp -----------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See http://www.boost.org/libs/chrono for documentation. +#include +#include +#include + +void another() { + boost::chrono::steady_clock::time_point t1=boost::chrono::steady_clock::now(); + boost::chrono::steady_clock::time_point t2=boost::chrono::steady_clock::now(); + std::cout << t2-t1 << std::endl; + return ; +} + diff --git a/src/boost/libs/chrono/test/clock.h b/src/boost/libs/chrono/test/clock.h new file mode 100644 index 00000000..3fd8eb55 --- /dev/null +++ b/src/boost/libs/chrono/test/clock.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +#ifndef CLOCK_H +#define CLOCK_H + +#include + +class Clock +{ + typedef boost::chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef boost::chrono::time_point time_point; + static const bool is_steady = false; + + static time_point now(); +}; + +#endif // CLOCK_H diff --git a/src/boost/libs/chrono/test/clock/clock_pass.cpp b/src/boost/libs/chrono/test/clock/clock_pass.cpp new file mode 100644 index 00000000..d19db166 --- /dev/null +++ b/src/boost/libs/chrono/test/clock/clock_pass.cpp @@ -0,0 +1,201 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// Copyright (c) Microsoft Corporation 2014 +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include +#include + +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +template +void check_clock_invariants() +{ + BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, ()); + BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, ()); + BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, ()); + BOOST_CHRONO_STATIC_ASSERT(Clock::is_steady || !Clock::is_steady, NOTHING, ()); + // to be replaced by has static member bool is_steady +} + +template +void check_clock_now() +{ + typename Clock::time_point t1 = Clock::now(); + (void)t1; +} + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + +template +void check_clock_now_ec() +{ + boost::system::error_code ec; + typename Clock::time_point t1 = Clock::now(ec); + (void)t1; + BOOST_TEST(ec.value()==0); +} + +template +void check_clock_now_throws() +{ + typename Clock::time_point t1 = Clock::now(boost::throws()); + (void)t1; +} + +#ifndef BOOST_NO_EXCEPTIONS + +template +void check_clock_now_err(int err) +{ + Clock::set_errno(err); + try { + typename Clock::time_point t1 = Clock::now(); + } catch (boost::system::system_error& ex) { + BOOST_TEST(ex.code().value()==err); +// BOOST_TEST(ex.code().category() == ::boost::system::system_category()); +// BOOST_TEST(std::string(ex.what()) == std::string("errored_clock")); + } + Clock::set_errno(0); +} +#endif + +template +void check_clock_now_ec_err(int err) +{ + Clock::set_errno(err); + boost::system::error_code ec; + typename Clock::time_point t1 = Clock::now(ec); + BOOST_TEST(ec.value()==err); +// BOOST_TEST(ec.category() == ::boost::system::system_category()); + Clock::set_errno(0); +} + +#ifndef BOOST_NO_EXCEPTIONS +template +void check_clock_now_throws_err(int err) +{ + Clock::set_errno(err); + try { + typename Clock::time_point t1 = Clock::now(boost::throws()); + BOOST_TEST(0&&"exception not thown"); + } catch (boost::system::system_error& ex) { + BOOST_TEST(ex.code().value()==err); +// BOOST_TEST(ex.code().category() == ::boost::system::system_category()); +// BOOST_TEST(std::string(ex.what()) == std::string("errored_clock")); + } + Clock::set_errno(0); +} +#endif +#endif + +int main() +{ + check_clock_invariants(); + check_clock_now(); + +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + check_clock_invariants(); + BOOST_CHRONO_STATIC_ASSERT(boost::chrono::steady_clock::is_steady, NOTHING, ()); + check_clock_now(); +#endif + + check_clock_invariants(); + BOOST_CHRONO_STATIC_ASSERT(!boost::chrono::system_clock::is_steady, NOTHING, ()); + check_clock_now(); + { + typedef boost::chrono::system_clock C; + C::time_point t1 = C::from_time_t(C::to_time_t(C::now())); + (void)t1; + } + { + typedef boost::chrono::system_clock C; + std::time_t t1 = C::to_time_t(C::now()); + (void)t1; + + } + { + BOOST_TEST((boost::chrono::system_clock::duration::min)() < + boost::chrono::system_clock::duration::zero()); + + } + +#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK) + check_clock_invariants(); + BOOST_CHRONO_STATIC_ASSERT(boost::chrono::thread_clock::is_steady, NOTHING, ()); + check_clock_now(); +#endif + +#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS) + check_clock_invariants(); + BOOST_CHRONO_STATIC_ASSERT(boost::chrono::process_real_cpu_clock::is_steady, NOTHING, ()); + check_clock_now(); + +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP + check_clock_invariants(); + BOOST_CHRONO_STATIC_ASSERT(boost::chrono::process_user_cpu_clock::is_steady, NOTHING, ()); + check_clock_now(); + + check_clock_invariants(); + BOOST_CHRONO_STATIC_ASSERT(boost::chrono::process_system_cpu_clock::is_steady, NOTHING, ()); + check_clock_now(); + + check_clock_invariants(); + BOOST_CHRONO_STATIC_ASSERT(boost::chrono::process_cpu_clock::is_steady, NOTHING, ()); + check_clock_now(); +#endif +#endif + + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + check_clock_now_ec(); + check_clock_now_throws(); + +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + check_clock_now_ec(); + check_clock_now_throws(); +#endif + + check_clock_now_ec(); + check_clock_now_throws(); + +#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK) + check_clock_now_ec(); + check_clock_now_throws(); +#endif + +#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS) + check_clock_now_ec(); + check_clock_now_throws(); + +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP + check_clock_now_ec(); + check_clock_now_throws(); + + check_clock_now_ec(); + check_clock_now_throws(); + + check_clock_now_ec(); + check_clock_now_throws(); +#endif +#endif + +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/clock/errored_clock.hpp b/src/boost/libs/chrono/test/clock/errored_clock.hpp new file mode 100644 index 00000000..d9e80e87 --- /dev/null +++ b/src/boost/libs/chrono/test/clock/errored_clock.hpp @@ -0,0 +1,62 @@ +// errored_clock.hpp --------------------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_CHRONO_ERRORED_CLOCKS_HPP +#define BOOST_CHRONO_ERRORED_CLOCKS_HPP + +#include +#include +#include +#include +#include +#include +#include + + class errored_clock + { + public: + typedef boost::chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef boost::chrono::time_point time_point; + static const bool is_steady = true; + static int errno_; + + static void set_errno(int err) { + errno_=err; + } + + // throws on error + static time_point now() { + boost::throw_exception( + boost::system::system_error( + errno_, + ::boost::system::system_category(), + "errored_clock" + ) + ); + return time_point(); + } + // never throws and set ec + static time_point now(boost::system::error_code & ec) { + if (::boost::chrono::is_throws(ec)) + { + boost::throw_exception( + boost::system::system_error( + errno_, + ::boost::system::system_category(), + "errored_clock" + ) + ); + } + ec.assign( errno_, ::boost::system::system_category() ); + return time_point(); + }; + }; + int errored_clock::errno_; + +#endif diff --git a/src/boost/libs/chrono/test/duration/arithmetic_pass.cpp b/src/boost/libs/chrono/test/duration/arithmetic_pass.cpp new file mode 100644 index 00000000..521ca644 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/arithmetic_pass.cpp @@ -0,0 +1,350 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +int main() +{ + // Default construct + { + //BOOST_CONSTEXPR + boost::chrono::minutes m; + //BOOST_CONSTEXPR_ASSERT(m.count() == 0); + (void)m; + } + + // UNARY PLUS + { + boost::chrono::minutes m(3); + boost::chrono::minutes m2 = +m; + BOOST_TEST(m.count() == m2.count()); + } + { + BOOST_CONSTEXPR boost::chrono::minutes m(3); + BOOST_CONSTEXPR boost::chrono::minutes m2(+m); + BOOST_CONSTEXPR_ASSERT(m.count() == m2.count()); + } + + // UNARY MINUS + { + boost::chrono::minutes m(3); + boost::chrono::minutes m2 = -m; + BOOST_TEST(m2.count() == -m.count()); + } + { + BOOST_CONSTEXPR boost::chrono::minutes m(3); + BOOST_CONSTEXPR boost::chrono::minutes m2 = -m; + BOOST_CONSTEXPR_ASSERT(m2.count() == -m.count()); + } + // PRE INCREMENT + { + boost::chrono::hours h(3); + boost::chrono::hours& href = ++h; + BOOST_TEST(&href == &h); + BOOST_TEST(h.count() == 4); + } + // POST INCREMENT + { + boost::chrono::hours h(3); + boost::chrono::hours h2 = h++; + BOOST_TEST(h.count() == 4); + BOOST_TEST(h2.count() == 3); + } + // PRE DECREMENT + { + boost::chrono::hours h(3); + boost::chrono::hours& href = --h; + BOOST_TEST(&href == &h); + BOOST_TEST(h.count() == 2); + } + // POST DECREMENT + { + boost::chrono::hours h(3); + boost::chrono::hours h2 = h--; + BOOST_TEST(h.count() == 2); + BOOST_TEST(h2.count() == 3); + } + // PLUS ASSIGN + { + boost::chrono::seconds s(3); + s += boost::chrono::seconds(2); + BOOST_TEST(s.count() == 5); + s += boost::chrono::minutes(2); + BOOST_TEST(s.count() == 125); + } + // MINUS ASSIGN + { + boost::chrono::seconds s(3); + s -= boost::chrono::seconds(2); + BOOST_TEST(s.count() == 1); + s -= boost::chrono::minutes(2); + BOOST_TEST(s.count() == -119); + } + // TIMES ASSIGN + { + boost::chrono::nanoseconds ns(3); + ns *= 5; + BOOST_TEST(ns.count() == 15); + } + // DIVIDE ASSIGN + { + boost::chrono::nanoseconds ns(15); + ns /= 5; + BOOST_TEST(ns.count() == 3); + } + // MODULUS ASSIGN duration + { + boost::chrono::microseconds us(11); + boost::chrono::microseconds us2(3); + us %= us2; + BOOST_TEST(us.count() == 2); + us %= boost::chrono::milliseconds(3); + BOOST_TEST(us.count() == 2); + } + // MODULUS ASSIGN Rep + { + boost::chrono::microseconds us(11); + us %= 3; + BOOST_TEST(us.count() == 2); + } + // PLUS + { + boost::chrono::seconds s1(3); + boost::chrono::seconds s2(5); + boost::chrono::seconds r = s1 + s2; + BOOST_TEST(r.count() == 8); + } + { + BOOST_CONSTEXPR boost::chrono::seconds s1(3); + BOOST_CONSTEXPR boost::chrono::seconds s2(5); + BOOST_CONSTEXPR boost::chrono::seconds r = s1 + s2; + BOOST_CONSTEXPR_ASSERT(r.count() == 8); + } + { + boost::chrono::seconds s1(3); + boost::chrono::microseconds s2(5); + boost::chrono::microseconds r = s1 + s2; + BOOST_TEST(r.count() == 3000005); + } + { + BOOST_CONSTEXPR boost::chrono::seconds s1(3); + BOOST_CONSTEXPR boost::chrono::microseconds s2(5); + BOOST_CONSTEXPR boost::chrono::microseconds r = s1 + s2; + BOOST_CONSTEXPR_ASSERT(r.count() == 3000005); + } + { + boost::chrono::duration > s1(3); + boost::chrono::duration > s2(5); + boost::chrono::duration > r = s1 + s2; + BOOST_TEST(r.count() == 75); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(3); + BOOST_CONSTEXPR boost::chrono::duration > s2(5); + BOOST_CONSTEXPR boost::chrono::duration > r = s1 + s2; + BOOST_CONSTEXPR_ASSERT(r.count() == 75); + } + { + boost::chrono::duration > s1(3); + boost::chrono::duration > s2(5); + boost::chrono::duration > r = s1 + s2; + BOOST_TEST(r.count() == 75); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(3); + BOOST_CONSTEXPR boost::chrono::duration > s2(5); + BOOST_CONSTEXPR boost::chrono::duration > r = s1 + s2; + BOOST_CONSTEXPR_ASSERT(r.count() == 75); + } + + // MINUS + { + boost::chrono::seconds s1(3); + boost::chrono::seconds s2(5); + boost::chrono::seconds r = s1 - s2; + BOOST_TEST(r.count() == -2); + } + { + BOOST_CONSTEXPR boost::chrono::seconds s1(3); + BOOST_CONSTEXPR boost::chrono::seconds s2(5); + BOOST_CONSTEXPR boost::chrono::seconds r = s1 - s2; + BOOST_CONSTEXPR_ASSERT(r.count() == -2); + } + { + boost::chrono::seconds s1(3); + boost::chrono::microseconds s2(5); + boost::chrono::microseconds r = s1 - s2; + BOOST_TEST(r.count() == 2999995); + } + { + BOOST_CONSTEXPR boost::chrono::seconds s1(3); + BOOST_CONSTEXPR boost::chrono::microseconds s2(5); + BOOST_CONSTEXPR boost::chrono::microseconds r = s1 - s2; + BOOST_CONSTEXPR_ASSERT(r.count() == 2999995); + } + { + boost::chrono::duration > s1(3); + boost::chrono::duration > s2(5); + boost::chrono::duration > r = s1 - s2; + BOOST_TEST(r.count() == -15); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(3); + BOOST_CONSTEXPR boost::chrono::duration > s2(5); + BOOST_CONSTEXPR boost::chrono::duration > r = s1 - s2; + BOOST_CONSTEXPR_ASSERT(r.count() == -15); + } + { + boost::chrono::duration > s1(3); + boost::chrono::duration > s2(5); + boost::chrono::duration > r = s1 - s2; + BOOST_TEST(r.count() == -15); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(3); + BOOST_CONSTEXPR boost::chrono::duration > s2(5); + BOOST_CONSTEXPR boost::chrono::duration > r = s1 - s2; + BOOST_CONSTEXPR_ASSERT(r.count() == -15); + } + + // TIMES rep + { + boost::chrono::nanoseconds ns(3); + boost::chrono::nanoseconds ns2 = ns * 5; + BOOST_TEST(ns2.count() == 15); + boost::chrono::nanoseconds ns3 = 6 * ns2; + BOOST_TEST(ns3.count() == 90); + } + { + BOOST_CONSTEXPR boost::chrono::nanoseconds ns(3); + BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns * 5; + BOOST_CONSTEXPR_ASSERT(ns2.count() == 15); + BOOST_CONSTEXPR boost::chrono::nanoseconds ns3 = 6 * ns2; + BOOST_CONSTEXPR_ASSERT(ns3.count() == 90); + } + + // DIVIDE duration + { + boost::chrono::nanoseconds ns1(15); + boost::chrono::nanoseconds ns2(5); + BOOST_TEST(ns1 / ns2 == 3); + } + { + BOOST_CONSTEXPR boost::chrono::nanoseconds ns1(15); + BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(5); + BOOST_CONSTEXPR_ASSERT(ns1 / ns2 == 3); + } + { + boost::chrono::microseconds us1(15); + boost::chrono::nanoseconds ns2(5); + BOOST_TEST(us1 / ns2 == 3000); + } + { + BOOST_CONSTEXPR boost::chrono::microseconds us1(15); + BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(5); + BOOST_CONSTEXPR_ASSERT(us1 / ns2 == 3000); + } + { + boost::chrono::duration > s1(30); + boost::chrono::duration > s2(5); + BOOST_TEST(s1 / s2 == 6); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(30); + BOOST_CONSTEXPR boost::chrono::duration > s2(5); + BOOST_CONSTEXPR_ASSERT(s1 / s2 == 6); + } + { + boost::chrono::duration > s1(30); + boost::chrono::duration > s2(5); + //BOOST_TEST(s1 / s2 == 20. / 3); + BOOST_TEST(3 * s1 == 20 * s2); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(30); + BOOST_CONSTEXPR boost::chrono::duration > s2(5); + //BOOST_CONSTEXPR_ASSERT(s1 / s2 == 20. / 3); + BOOST_TEST(3 * s1 == 20 * s2); + } + // DIVIDE rep + { + boost::chrono::nanoseconds ns(15); + boost::chrono::nanoseconds ns2 = ns / 5; + BOOST_TEST(ns2.count() == 3); + } + { + BOOST_CONSTEXPR boost::chrono::nanoseconds ns(15); + BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns / 5; + BOOST_CONSTEXPR_ASSERT(ns2.count() == 3); + } + + // MODULUS duration + + { + boost::chrono::nanoseconds ns1(15); + boost::chrono::nanoseconds ns2(6); + boost::chrono::nanoseconds r = ns1 % ns2; + BOOST_TEST(r.count() == 3); + } + { + BOOST_CONSTEXPR boost::chrono::nanoseconds ns1(15); + BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(6); + BOOST_CONSTEXPR boost::chrono::nanoseconds r = ns1 % ns2; + BOOST_CONSTEXPR_ASSERT(r.count() == 3); + } + { + boost::chrono::microseconds us1(15); + boost::chrono::nanoseconds ns2(28); + boost::chrono::nanoseconds r = us1 % ns2; + BOOST_TEST(r.count() == 20); + } + { + BOOST_CONSTEXPR boost::chrono::microseconds us1(15); + BOOST_CONSTEXPR boost::chrono::nanoseconds ns2(28); + BOOST_CONSTEXPR boost::chrono::nanoseconds r = us1 % ns2; + BOOST_CONSTEXPR_ASSERT(r.count() == 20); + } + { + boost::chrono::duration > s1(6); + boost::chrono::duration > s2(3); + boost::chrono::duration > r = s1 % s2; + BOOST_TEST(r.count() == 24); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(6); + BOOST_CONSTEXPR boost::chrono::duration > s2(3); + BOOST_CONSTEXPR boost::chrono::duration > r = s1 % s2; + BOOST_CONSTEXPR_ASSERT(r.count() == 24); + } + // MODULUS rep + { + boost::chrono::nanoseconds ns(15); + boost::chrono::nanoseconds ns2 = ns % 6; + BOOST_TEST(ns2.count() == 3); + } + { + BOOST_CONSTEXPR boost::chrono::nanoseconds ns(15); + BOOST_CONSTEXPR boost::chrono::nanoseconds ns2 = ns % 6; + BOOST_CONSTEXPR_ASSERT(ns2.count() == 3); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/duration/comparisons_pass.cpp b/src/boost/libs/chrono/test/duration/comparisons_pass.cpp new file mode 100644 index 00000000..79deaaa1 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/comparisons_pass.cpp @@ -0,0 +1,222 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +int main() +{ + { + boost::chrono::seconds s1(3); + boost::chrono::seconds s2(3); + BOOST_TEST(s1 == s2); + BOOST_TEST(! (s1 != s2)); + } + { + BOOST_CONSTEXPR boost::chrono::seconds s1(3); + BOOST_CONSTEXPR boost::chrono::seconds s2(3); + BOOST_CONSTEXPR_ASSERT(s1 == s2); + BOOST_CONSTEXPR_ASSERT(!(s1 != s2)); + } + { + boost::chrono::seconds s1(3); + boost::chrono::seconds s2(4); + BOOST_TEST(! (s1 == s2)); + BOOST_TEST(s1 != s2); + } + { + BOOST_CONSTEXPR boost::chrono::seconds s1(3); + BOOST_CONSTEXPR boost::chrono::seconds s2(4); + BOOST_CONSTEXPR_ASSERT(! (s1 == s2)); + BOOST_CONSTEXPR_ASSERT(s1 != s2); + } + { + boost::chrono::milliseconds s1(3); + boost::chrono::microseconds s2(3000); + BOOST_TEST(s1 == s2); + BOOST_TEST(! (s1 != s2)); + } + { + BOOST_CONSTEXPR boost::chrono::milliseconds s1(3); + BOOST_CONSTEXPR boost::chrono::microseconds s2(3000); + BOOST_CONSTEXPR_ASSERT(s1 == s2); + BOOST_CONSTEXPR_ASSERT(! (s1 != s2)); + } + { + boost::chrono::milliseconds s1(3); + boost::chrono::microseconds s2(4000); + BOOST_TEST(! (s1 == s2)); + BOOST_TEST(s1 != s2); + } + { + BOOST_CONSTEXPR boost::chrono::milliseconds s1(3); + BOOST_CONSTEXPR boost::chrono::microseconds s2(4000); + BOOST_CONSTEXPR_ASSERT(! (s1 == s2)); + BOOST_CONSTEXPR_ASSERT(s1 != s2); + } + { + boost::chrono::duration > s1(9); + boost::chrono::duration > s2(10); + BOOST_TEST(s1 == s2); + BOOST_TEST(! (s1 != s2)); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(9); + BOOST_CONSTEXPR boost::chrono::duration > s2(10); + BOOST_CONSTEXPR_ASSERT(s1 == s2); + BOOST_CONSTEXPR_ASSERT(! (s1 != s2)); + } + { + boost::chrono::duration > s1(10); + boost::chrono::duration > s2(9); + BOOST_TEST(! (s1 == s2)); + BOOST_TEST(s1 != s2); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(10); + BOOST_CONSTEXPR boost::chrono::duration > s2(9); + BOOST_CONSTEXPR_ASSERT(! (s1 == s2)); + BOOST_CONSTEXPR_ASSERT(s1 != s2); + } + { + boost::chrono::duration > s1(9); + boost::chrono::duration > s2(10); + BOOST_TEST(s1 == s2); + BOOST_TEST(! (s1 != s2)); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(9); + BOOST_CONSTEXPR boost::chrono::duration > s2(10); + BOOST_CONSTEXPR_ASSERT(s1 == s2); + BOOST_CONSTEXPR_ASSERT(! (s1 != s2)); + } + { + boost::chrono::seconds s1(3); + boost::chrono::seconds s2(3); + BOOST_TEST(! (s1 < s2)); + BOOST_TEST(! (s1 > s2)); + BOOST_TEST( (s1 <= s2)); + BOOST_TEST( (s1 >= s2)); + } + { + BOOST_CONSTEXPR boost::chrono::seconds s1(3); + BOOST_CONSTEXPR boost::chrono::seconds s2(3); + BOOST_CONSTEXPR_ASSERT(! (s1 < s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 > s2)); + BOOST_CONSTEXPR_ASSERT( (s1 <= s2)); + BOOST_CONSTEXPR_ASSERT( (s1 >= s2)); + } + { + boost::chrono::seconds s1(3); + boost::chrono::seconds s2(4); + BOOST_TEST( (s1 < s2)); + BOOST_TEST(! (s1 > s2)); + BOOST_TEST( (s1 <= s2)); + BOOST_TEST(! (s1 >= s2)); + } + { + BOOST_CONSTEXPR boost::chrono::seconds s1(3); + BOOST_CONSTEXPR boost::chrono::seconds s2(4); + BOOST_CONSTEXPR_ASSERT( (s1 < s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 > s2)); + BOOST_CONSTEXPR_ASSERT( (s1 <= s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 >= s2)); + } + { + boost::chrono::milliseconds s1(3); + boost::chrono::microseconds s2(3000); + BOOST_TEST(! (s1 < s2)); + BOOST_TEST(! (s1 > s2)); + BOOST_TEST( (s1 <= s2)); + BOOST_TEST( (s1 >= s2)); + } + { + BOOST_CONSTEXPR boost::chrono::milliseconds s1(3); + BOOST_CONSTEXPR boost::chrono::microseconds s2(3000); + BOOST_CONSTEXPR_ASSERT(! (s1 < s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 > s2)); + BOOST_CONSTEXPR_ASSERT( (s1 <= s2)); + BOOST_CONSTEXPR_ASSERT( (s1 >= s2)); + } + { + boost::chrono::milliseconds s1(3); + boost::chrono::microseconds s2(4000); + BOOST_TEST( (s1 < s2)); + BOOST_TEST(! (s1 > s2)); + BOOST_TEST( (s1 <= s2)); + BOOST_TEST(! (s1 >= s2)); + } + { + BOOST_CONSTEXPR boost::chrono::milliseconds s1(3); + BOOST_CONSTEXPR boost::chrono::microseconds s2(4000); + BOOST_CONSTEXPR_ASSERT( (s1 < s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 > s2)); + BOOST_CONSTEXPR_ASSERT( (s1 <= s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 >= s2)); + } + { + boost::chrono::duration > s1(9); + boost::chrono::duration > s2(10); + BOOST_TEST(! (s1 < s2)); + BOOST_TEST(! (s1 > s2)); + BOOST_TEST( (s1 <= s2)); + BOOST_TEST( (s1 >= s2)); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(9); + BOOST_CONSTEXPR boost::chrono::duration > s2(10); + BOOST_CONSTEXPR_ASSERT(! (s1 < s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 > s2)); + BOOST_CONSTEXPR_ASSERT( (s1 <= s2)); + BOOST_CONSTEXPR_ASSERT( (s1 >= s2)); + } + { + boost::chrono::duration > s1(10); + boost::chrono::duration > s2(9); + BOOST_TEST(! (s1 < s2)); + BOOST_TEST( (s1 > s2)); + BOOST_TEST(! (s1 <= s2)); + BOOST_TEST( (s1 >= s2)); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(10); + BOOST_CONSTEXPR boost::chrono::duration > s2(9); + BOOST_CONSTEXPR_ASSERT(! (s1 < s2)); + BOOST_CONSTEXPR_ASSERT( (s1 > s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 <= s2)); + BOOST_CONSTEXPR_ASSERT( (s1 >= s2)); + } + { + boost::chrono::duration > s1(9); + boost::chrono::duration > s2(10); + BOOST_TEST(! (s1 < s2)); + BOOST_TEST(! (s1 > s2)); + BOOST_TEST( (s1 <= s2)); + BOOST_TEST( (s1 >= s2)); + } + { + BOOST_CONSTEXPR boost::chrono::duration > s1(9); + BOOST_CONSTEXPR boost::chrono::duration > s2(10); + BOOST_CONSTEXPR_ASSERT(! (s1 < s2)); + BOOST_CONSTEXPR_ASSERT(! (s1 > s2)); + BOOST_CONSTEXPR_ASSERT( (s1 <= s2)); + BOOST_CONSTEXPR_ASSERT( (s1 >= s2)); + } + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/duration/cons/convert_float_to_int_fail.cpp b/src/boost/libs/chrono/test/duration/cons/convert_float_to_int_fail.cpp new file mode 100644 index 00000000..f3024010 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/cons/convert_float_to_int_fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// conversions from floating point to integral durations disallowed + +#include + +void test() +{ + boost::chrono::duration d; + boost::chrono::duration i = d; +} diff --git a/src/boost/libs/chrono/test/duration/cons/convert_inexact_fail.cpp b/src/boost/libs/chrono/test/duration/cons/convert_inexact_fail.cpp new file mode 100644 index 00000000..a912daa0 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/cons/convert_inexact_fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// inexact conversions disallowed for integral reps + +#include + +void test() +{ + boost::chrono::microseconds us(1); + boost::chrono::milliseconds ms = us; +} diff --git a/src/boost/libs/chrono/test/duration/cons/implicit_constructot_fail.cpp b/src/boost/libs/chrono/test/duration/cons/implicit_constructot_fail.cpp new file mode 100644 index 00000000..72ea507b --- /dev/null +++ b/src/boost/libs/chrono/test/duration/cons/implicit_constructot_fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// test for explicit + +#include + +#include "../../rep.h" + +void test() +{ + boost::chrono::duration d = 1; +} diff --git a/src/boost/libs/chrono/test/duration/cons/non_implicit_convertible_rep_fail.cpp b/src/boost/libs/chrono/test/duration/cons/non_implicit_convertible_rep_fail.cpp new file mode 100644 index 00000000..0be0a589 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/cons/non_implicit_convertible_rep_fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// Rep2 shall be implicitly convertible to rep + +#include + +#include "../../rep.h" + +void test() +{ + boost::chrono::duration d(1); +} diff --git a/src/boost/libs/chrono/test/duration/cons/treat_as_floating_point_Rep2_true_fail.cpp b/src/boost/libs/chrono/test/duration/cons/treat_as_floating_point_Rep2_true_fail.cpp new file mode 100644 index 00000000..47c8b2e0 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/cons/treat_as_floating_point_Rep2_true_fail.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// treat_as_floating_point::value must be false + +#include + +void test() +{ + boost::chrono::duration d(1.); +} diff --git a/src/boost/libs/chrono/test/duration/constructor_pass.cpp b/src/boost/libs/chrono/test/duration/constructor_pass.cpp new file mode 100644 index 00000000..54b76b70 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/constructor_pass.cpp @@ -0,0 +1,134 @@ +//===----------------------------------------------------------------------===// +// +// 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 "../rep.h" +#include + +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +template +void +check_default() +{ + { + D d; + BOOST_TEST(d.count() == typename D::rep()); + } +} +template +void +check_constexpr() +{ + BOOST_CONSTEXPR D d(0); + BOOST_CONSTEXPR_ASSERT(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); + { + BOOST_CONSTEXPR boost::chrono::milliseconds ms(1); + BOOST_CONSTEXPR boost::chrono::microseconds us = ms; + BOOST_CONSTEXPR_ASSERT(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); + { + BOOST_CONSTEXPR boost::chrono::duration us(1); + BOOST_CONSTEXPR boost::chrono::duration ms = us; + BOOST_CONSTEXPR_ASSERT(ms.count() == 1./1000); + } + } + // Convert int to float + { + boost::chrono::duration i(3); + boost::chrono::duration d = i; + BOOST_TEST(d.count() == 3); + { + BOOST_CONSTEXPR boost::chrono::duration i(3); + BOOST_CONSTEXPR boost::chrono::duration d = i; + BOOST_CONSTEXPR_ASSERT(d.count() == 3); + } + } + // default constructor + { + check_default >(); + } + { + check_constexpr >(); + } + // constructor from rep + { + check_from_rep >(5); + { + BOOST_CONSTEXPR boost::chrono::duration d(5); + BOOST_CONSTEXPR_ASSERT(d.count() == 5); + } + check_from_rep > >(5); + { + BOOST_CONSTEXPR boost::chrono::duration > d(5); + BOOST_CONSTEXPR_ASSERT(d.count() == 5); + } + check_from_rep > >(Rep(3)); + { + BOOST_CONSTEXPR boost::chrono::duration > d(Rep(3)); + BOOST_CONSTEXPR_ASSERT(d.count() == Rep(3)); + } + check_from_rep > >(5.5); + { + BOOST_CONSTEXPR boost::chrono::duration > d(5.5); + BOOST_CONSTEXPR_ASSERT(d.count() == 5.5); + } + + + } + // constructor from other rep + { + boost::chrono::duration d(5); + BOOST_TEST(d.count() == 5); + { + BOOST_CONSTEXPR boost::chrono::duration d(5); + BOOST_CONSTEXPR_ASSERT(d.count() == 5); + } + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/duration/default_ratio_pass.cpp b/src/boost/libs/chrono/test/duration/default_ratio_pass.cpp new file mode 100644 index 00000000..1d8ad3a2 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/default_ratio_pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// duration +// Test default template arg: + +// template > +// class duration; + +#include +#include +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +BOOST_CHRONO_STATIC_ASSERT((boost::is_same< + boost::chrono::duration >, + boost::chrono::duration +>::value), NOTHING, ()); diff --git a/src/boost/libs/chrono/test/duration/duration_cast_int_fail.cpp b/src/boost/libs/chrono/test/duration/duration_cast_int_fail.cpp new file mode 100644 index 00000000..77b03b74 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/duration_cast_int_fail.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// ToDuration must be an instantiation of duration. + +#include + +void test() +{ + boost::chrono::duration_cast(boost::chrono::milliseconds(3)); +} diff --git a/src/boost/libs/chrono/test/duration/duration_cast_pass.cpp b/src/boost/libs/chrono/test/duration/duration_cast_pass.cpp new file mode 100644 index 00000000..0364faa3 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/duration_cast_pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + + +template +void +test(const FromDuration& f, const ToDuration& d) +{ +//~ #if defined(BOOST_NO_CXX11_DECLTYPE) + //~ typedef BOOST_TYPEOF_TPL(boost::chrono::duration_cast(f)) R; +//~ #else + //~ typedef decltype(boost::chrono::duration_cast(f)) R; +//~ #endif + //~ BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, (R, ToDuration)); + BOOST_TEST(boost::chrono::duration_cast(f) == d); +} + +int main() +{ + test(boost::chrono::milliseconds(7265000), boost::chrono::hours(2)); + test(boost::chrono::milliseconds(7265000), boost::chrono::minutes(121)); + test(boost::chrono::milliseconds(7265000), boost::chrono::seconds(7265)); + test(boost::chrono::milliseconds(7265000), boost::chrono::milliseconds(7265000)); + test(boost::chrono::milliseconds(7265000), boost::chrono::microseconds(7265000000LL)); + test(boost::chrono::milliseconds(7265000), boost::chrono::nanoseconds(7265000000000LL)); + test(boost::chrono::milliseconds(7265000), + boost::chrono::duration >(7265./3600)); + test(boost::chrono::duration >(9), + boost::chrono::duration >(10)); + { + BOOST_CONSTEXPR boost::chrono::hours h = boost::chrono::duration_cast(boost::chrono::milliseconds(7265000)); + BOOST_CONSTEXPR_ASSERT(h.count() == 2); + } + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/duration/duration_duration_fail.cpp b/src/boost/libs/chrono/test/duration/duration_duration_fail.cpp new file mode 100644 index 00000000..19e6928e --- /dev/null +++ b/src/boost/libs/chrono/test/duration/duration_duration_fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// duration +// If a program instantiates duration with a duration type for the template +// argument Rep a diagnostic is required. + +#include + +void test() +{ + typedef boost::chrono::duration D; + D d; +} diff --git a/src/boost/libs/chrono/test/duration/duration_values_pass.cpp b/src/boost/libs/chrono/test/duration/duration_values_pass.cpp new file mode 100644 index 00000000..9d6b84b1 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/duration_values_pass.cpp @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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 "../rep.h" +#if defined BOOST_NO_CXX11_NUMERIC_LIMITS || defined BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +template +void check_max() +{ + typedef typename D::rep Rep; + Rep max_rep = (boost::chrono::duration_values::max)(); + BOOST_TEST((D::max)().count() == max_rep); + { + typedef typename D::rep Rep; + BOOST_CHRONO_LIB_CONSTEXPR Rep max_rep = (boost::chrono::duration_values::max)(); + BOOST_CONSTEXPR_ASSERT((D::max)().count() == max_rep); + } +} + +template +void check_min() +{ + typedef typename D::rep Rep; + Rep min_rep = (boost::chrono::duration_values::min)(); + BOOST_TEST((D::min)().count() == min_rep); + { + typedef typename D::rep Rep; + BOOST_CHRONO_LIB_CONSTEXPR Rep min_rep = (boost::chrono::duration_values::min)(); + BOOST_CONSTEXPR_ASSERT((D::min)().count() == min_rep); + + } +} + +template +void check_zero() +{ + typedef typename D::rep Rep; + Rep zero_rep = boost::chrono::duration_values::zero(); + BOOST_TEST(D::zero().count() == zero_rep); + { + typedef typename D::rep Rep; + BOOST_CONSTEXPR Rep zero_rep = boost::chrono::duration_values::zero(); + BOOST_CONSTEXPR_ASSERT(D::zero().count() == zero_rep); + + } +} + + +int main() +{ + check_max >(); + check_max >(); + check_min >(); + check_min >(); + check_zero >(); + check_zero >(); + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/duration/nonmember/divide_rep2_fail.cpp b/src/boost/libs/chrono/test/duration/nonmember/divide_rep2_fail.cpp new file mode 100644 index 00000000..649f17ea --- /dev/null +++ b/src/boost/libs/chrono/test/duration/nonmember/divide_rep2_fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 "../../rep.h" + +void test() +{ + boost::chrono::duration d(Rep(15)); + d = d / 5; +} diff --git a/src/boost/libs/chrono/test/duration/nonmember/modulus_rep2_fail.cpp b/src/boost/libs/chrono/test/duration/nonmember/modulus_rep2_fail.cpp new file mode 100644 index 00000000..b5b8c7e4 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/nonmember/modulus_rep2_fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 "../../rep.h" + +void test() +{ + boost::chrono::duration d(Rep(15)); + d = d % 5; +} diff --git a/src/boost/libs/chrono/test/duration/nonmember/times_rep2_lhs_fail.cpp b/src/boost/libs/chrono/test/duration/nonmember/times_rep2_lhs_fail.cpp new file mode 100644 index 00000000..84c6a405 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/nonmember/times_rep2_lhs_fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 "../../rep.h" + +void test() +{ + boost::chrono::duration d; + d = 5 * d; +} diff --git a/src/boost/libs/chrono/test/duration/nonmember/times_rep2_rhs_fail.cpp b/src/boost/libs/chrono/test/duration/nonmember/times_rep2_rhs_fail.cpp new file mode 100644 index 00000000..0172b999 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/nonmember/times_rep2_rhs_fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 "../../rep.h" + +void test() +{ + boost::chrono::duration d; + d = d * 5; +} diff --git a/src/boost/libs/chrono/test/duration/positive_num_fail.cpp b/src/boost/libs/chrono/test/duration/positive_num_fail.cpp new file mode 100644 index 00000000..fbd25f67 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/positive_num_fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// duration +// Period::num must be positive, diagnostic required. + +#include + +void test() +{ + typedef boost::chrono::duration > D; + D d; +} diff --git a/src/boost/libs/chrono/test/duration/ratio_alias_pass.cpp b/src/boost/libs/chrono/test/duration/ratio_alias_pass.cpp new file mode 100644 index 00000000..a949032a --- /dev/null +++ b/src/boost/libs/chrono/test/duration/ratio_alias_pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// duration +// Period shall be a specialization of ratio, diagnostic required. + +#include + +void test() +{ + typedef boost::chrono::duration, + boost::ratio<1,3> + > + > D; + D d; + (void)d; +} diff --git a/src/boost/libs/chrono/test/duration/ratio_fail.cpp b/src/boost/libs/chrono/test/duration/ratio_fail.cpp new file mode 100644 index 00000000..5ea4b60b --- /dev/null +++ b/src/boost/libs/chrono/test/duration/ratio_fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// duration +// Period shall be a specialization of ratio, diagnostic required. + +#include + +void test() +{ + typedef boost::chrono::duration D; + D d; +} diff --git a/src/boost/libs/chrono/test/duration/rounding_pass.cpp b/src/boost/libs/chrono/test/duration/rounding_pass.cpp new file mode 100644 index 00000000..06a32a1b --- /dev/null +++ b/src/boost/libs/chrono/test/duration/rounding_pass.cpp @@ -0,0 +1,105 @@ +// Copyright 2013 Krzysztof Czainski +// Copyright 2013 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/* + * @file chrono_rounding.cpp + * + * @since 2013-11-22 + * @author Krzysztof Czainski <1czajnik@gmail.com> + */ + +#include +#include +#include +#include + +#include +#include + +using namespace boost::chrono; + +void test_floor() +{ + BOOST_TEST_EQ( seconds(-2), floor( milliseconds(-2000) ) ); + BOOST_TEST_EQ( seconds(-2), floor( milliseconds(-1999) ) ); + BOOST_TEST_EQ( seconds(-2), floor( milliseconds(-1001) ) ); + BOOST_TEST_EQ( seconds(-1), floor( milliseconds(-1000) ) ); + BOOST_TEST_EQ( seconds(-1), floor( milliseconds(-999) ) ); + BOOST_TEST_EQ( seconds(-1), floor( milliseconds(-1) ) ); + BOOST_TEST_EQ( seconds(0), floor( milliseconds(0) ) ); + BOOST_TEST_EQ( seconds(0), floor( milliseconds(1) ) ); + BOOST_TEST_EQ( seconds(0), floor( milliseconds(999) ) ); + BOOST_TEST_EQ( seconds(1), floor( milliseconds(1000) ) ); + BOOST_TEST_EQ( seconds(1), floor( milliseconds(1001) ) ); + BOOST_TEST_EQ( seconds(1), floor( milliseconds(1999) ) ); + BOOST_TEST_EQ( seconds(2), floor( milliseconds(2000) ) ); + + { + // check that int32 isn't overflowed in intermediate calculations: + typedef duration sec32; + typedef duration< boost::int32_t, boost::ratio<999,1000> > sec32_m1ms; + BOOST_TEST_EQ( sec32(-999000000), floor( sec32_m1ms(-1000000000) ) ); + BOOST_TEST_EQ( sec32( 999000000), floor( sec32_m1ms( 1000000000) ) ); + } +} + +void test_ceil() +{ + BOOST_TEST_EQ( seconds(-2), ceil( milliseconds(-2000) ) ); + BOOST_TEST_EQ( seconds(-1), ceil( milliseconds(-1999) ) ); + BOOST_TEST_EQ( seconds(-1), ceil( milliseconds(-1001) ) ); + BOOST_TEST_EQ( seconds(-1), ceil( milliseconds(-1000) ) ); + BOOST_TEST_EQ( seconds(0), ceil( milliseconds(-999) ) ); + BOOST_TEST_EQ( seconds(0), ceil( milliseconds(-1) ) ); + BOOST_TEST_EQ( seconds(0), ceil( milliseconds(0) ) ); + BOOST_TEST_EQ( seconds(1), ceil( milliseconds(1) ) ); + BOOST_TEST_EQ( seconds(1), ceil( milliseconds(999) ) ); + BOOST_TEST_EQ( seconds(1), ceil( milliseconds(1000) ) ); + BOOST_TEST_EQ( seconds(2), ceil( milliseconds(1001) ) ); + BOOST_TEST_EQ( seconds(2), ceil( milliseconds(1999) ) ); + BOOST_TEST_EQ( seconds(2), ceil( milliseconds(2000) ) ); + { + // check that int32 isn't overflowed in intermediate calculations: + typedef duration sec32; + typedef duration< boost::int32_t, boost::ratio<999,1000> > sec32_m1ms; + BOOST_TEST_EQ( sec32(-999000000), ceil( sec32_m1ms(-1000000000) ) ); + BOOST_TEST_EQ( sec32( 999000000), ceil( sec32_m1ms( 1000000000) ) ); + } +} + +void test_round() +{ + // to even on tie + BOOST_TEST_EQ( seconds(-2), round( milliseconds(-2000) ) ); + BOOST_TEST_EQ( seconds(-2), round( milliseconds(-1500) ) ); + BOOST_TEST_EQ( seconds(-1), round( milliseconds(-1499) ) ); + BOOST_TEST_EQ( seconds(-1), round( milliseconds(-1000) ) ); + BOOST_TEST_EQ( seconds(0), round( milliseconds(-500) ) ); + BOOST_TEST_EQ( seconds(0), round( milliseconds(-499) ) ); + BOOST_TEST_EQ( seconds(0), round( milliseconds(0) ) ); + BOOST_TEST_EQ( seconds(0), round( milliseconds(499) ) ); + BOOST_TEST_EQ( seconds(0), round( milliseconds(500) ) ); + BOOST_TEST_EQ( seconds(1), round( milliseconds(1000) ) ); + BOOST_TEST_EQ( seconds(1), round( milliseconds(1499) ) ); + BOOST_TEST_EQ( seconds(2), round( milliseconds(1500) ) ); + BOOST_TEST_EQ( seconds(2), round( milliseconds(2000) ) ); + { + // check that int32 isn't overflowed in intermediate calculations: + typedef duration sec32; + typedef duration< boost::int32_t, boost::ratio<999,1000> > sec32_m1ms; + BOOST_TEST_EQ( sec32(-999000000), round( sec32_m1ms(-1000000000) ) ); + BOOST_TEST_EQ( sec32( 999000000), round( sec32_m1ms( 1000000000) ) ); + } +} + +int main() +{ + test_floor(); + test_ceil(); + test_round(); + return boost::report_errors(); + +} diff --git a/src/boost/libs/chrono/test/duration/typedefs_pass.cpp b/src/boost/libs/chrono/test/duration/typedefs_pass.cpp new file mode 100644 index 00000000..2f9d2ef3 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/typedefs_pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +template +void check_duration() +{ + typedef typename D::rep Rep; + typedef typename D::period Period; + BOOST_CHRONO_STATIC_ASSERT(boost::is_signed::value, NOTHING, ()); + BOOST_CHRONO_STATIC_ASSERT(boost::is_integral::value, NOTHING, ()); + BOOST_CHRONO_STATIC_ASSERT(std::numeric_limits::digits >= ExpectedDigits, NOTHING, ()); + BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, ()); +} + +void test() +{ + check_duration >(); + check_duration >(); + check_duration >(); + check_duration(); + check_duration(); + check_duration(); +} diff --git a/src/boost/libs/chrono/test/duration/types_pass.cpp b/src/boost/libs/chrono/test/duration/types_pass.cpp new file mode 100644 index 00000000..568ce0e2 --- /dev/null +++ b/src/boost/libs/chrono/test/duration/types_pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// duration +// Test nested types + +// typedef Rep rep; +// typedef Period period; + +#include +#include +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +typedef boost::chrono::duration > D; +BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, ()); +BOOST_CHRONO_STATIC_ASSERT((boost::is_same >::value), NOTHING, ()); diff --git a/src/boost/libs/chrono/test/intmax_c.cpp b/src/boost/libs/chrono/test/intmax_c.cpp new file mode 100644 index 00000000..e3dab7ac --- /dev/null +++ b/src/boost/libs/chrono/test/intmax_c.cpp @@ -0,0 +1,19 @@ +// intmax_c.cpp --------------------------------------------------------------// + +// 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 + +#ifdef INTMAX_C +#define BOOST_INTMAX_C(a) INTMAX_C(a) +#else +#define BOOST_INTMAX_C(a) a##LL +#endif + +boost::intmax_t i = BOOST_INTMAX_C(1000000000); +int main() { + return (i); +} diff --git a/src/boost/libs/chrono/test/io/duration_input.cpp b/src/boost/libs/chrono/test/io/duration_input.cpp new file mode 100644 index 00000000..1ad8efc5 --- /dev/null +++ b/src/boost/libs/chrono/test/io/duration_input.cpp @@ -0,0 +1,124 @@ +// Distributed under the Boost Software License, Version 1.0. +// Copyright 2011 Vicente J. Botet Escriba +// See http://www.boost.org/LICENSE_1_0.txt + +#include +//#include +#include +#include + + +template +void test_good(const char* str, D res) +{ + std::istringstream in(str); + D d(0); + in >> d; + BOOST_TEST(in.eof()); + BOOST_TEST(!in.fail()); + BOOST_TEST(d == res); + std::cout << str << " " << res << " " << d << std::endl; +} + +template +void test_fail(const char* str, DFail res) +{ + { + std::istringstream in(str); + DFail d = DFail::zero(); + in >> d; + BOOST_TEST(in.fail()); + BOOST_TEST(d == DFail::zero()); + std::cout << str << " " << res << " " << d << std::endl; + } +} + +template +void test_not_eof(const char* str, D res) +{ + { + std::istringstream in(str); + D d = D::zero(); + in >> d; + BOOST_TEST(!in.eof()); + BOOST_TEST(d == res); + std::cout << str << " " << res << " " << d << std::endl; + } +} +int main() +{ + using namespace boost::chrono; + using namespace boost; + + test_good("5000", 5000); + + std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl; + test_good("5000 hours", hours(5000)); + std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl; + test_good("5000 minutes", minutes(5000)); + test_good("5000 seconds", seconds(5000)); + test_fail("1.0 second", seconds(1)); + + test_good("1.0 second", duration >(1)); + /* BUG with DURATION_GET +../../../boost/math/common_factor_rt.hpp: In function 'RingType boost::math::detail::gcd_euclidean(RingType, RingType) [with RingType = long double]': +../../../boost/math/common_factor_rt.hpp:122: instantiated from 'IntegerType boost::math::detail::gcd_integer(const IntegerType&, const IntegerType&) [with IntegerType = long double]' +../../../boost/math/common_factor_rt.hpp:240: instantiated from 'T boost::math::detail::gcd_optimal_evaluator_helper_t::operator()(const T&, const T&) [with T = long double]' +../../../boost/math/common_factor_rt.hpp:290: instantiated from 'T boost::math::detail::gcd_optimal_evaluator::operator()(const T&, const T&) [with T = long double]' +../../../boost/math/common_factor_rt.hpp:442: instantiated from 'T boost::math::detail::gcd_optimal(const T&, const T&) [with T = long double]' +../../../boost/math/common_factor_rt.hpp:473: instantiated from 'typename boost::math::gcd_evaluator::result_type boost::math::gcd_evaluator::operator()(const IntegerType&, const IntegerType&) const [with IntegerType = long double]' +../../../boost/math/common_factor_rt.hpp:505: instantiated from 'IntegerType boost::math::gcd(const IntegerType&, const IntegerType&) [with IntegerType = long double]' +../../../boost/chrono/io/duration_get.hpp:239: instantiated from 'InputIterator boost::chrono::duration_get::get(InputIterator, InputIterator, std::ios_base&, std::_Ios_Iostate&, boost::chrono::duration&, const CharT*, const CharT*) const [with Rep = double, Period = boost::ratio<1l, 1l>, CharT = char, InputIterator = std::istreambuf_iterator >]' +../../../boost/chrono/io/duration_get.hpp:294: instantiated from 'InputIterator boost::chrono::duration_get::get(InputIterator, InputIterator, std::ios_base&, std::_Ios_Iostate&, boost::chrono::duration&) const [with Rep = double, Period = boost::ratio<1l, 1l>, CharT = char, InputIterator = std::istreambuf_iterator >]' +../../../boost/chrono/io/duration_io.hpp:593: instantiated from 'std::basic_istream<_CharT, _Traits>& boost::chrono::operator>>(std::basic_istream<_CharT, _Traits>&, boost::chrono::duration&) [with CharT = char, Traits = std::char_traits, Rep = double, Period = boost::ratio<1l, 1l>]' +io/duration_input.cpp:15: instantiated from 'void test_good(const char*, D) [with D = boost::chrono::duration >]' +io/duration_input.cpp:52: instantiated from here +../../../boost/math/common_factor_rt.hpp:102: error: invalid operands of types 'long double' and 'long double' to binary 'operator%' +../../../boost/math/common_factor_rt.hpp:102: error: in evaluation of 'operator%=(long double, long double)' +../../../boost/math/common_factor_rt.hpp:106: error: invalid operands of types 'long double' and 'long double' to binary 'operator%' +../../../boost/math/common_factor_rt.hpp:106: error: in evaluation of 'operator%=(long double, long double)' + * + */ + test_good("1 second", seconds(1)); + test_not_eof("1 second ", seconds(1)); + test_not_eof("1 seconde", seconds(1)); + test_good("1 seconds", seconds(1)); + test_good("0 seconds", seconds(0)); + test_good("-1 seconds", seconds(-1)); + test_good("5000 milliseconds", milliseconds(5000)); + test_good("5000 microseconds", microseconds(5000)); + test_good("5000 nanoseconds", nanoseconds(5000)); + test_good("5000 deciseconds", duration (5000)); + test_good("5000 [1/30]seconds", duration > (5000)); + test_good("5000 [1/30]second", duration > (5000)); + test_good("5000 h", hours(5000)); +#if BOOST_CHRONO_VERSION==2 + test_good("5000 min", minutes(5000)); +#else + test_good("5000 m", minutes(5000)); +#endif + test_good("5000 s", seconds(5000)); + test_good("5000 ms", milliseconds(5000)); + test_good("5000 ns", nanoseconds(5000)); + test_good("5000 ds", duration (5000)); + test_good("5000 [1/30]s", duration > (5000)); + test_not_eof("5000 [1/30]ss", duration > (5000)); + std::cout << __LINE__<< "*****" << std::endl; + test_good("5000 milliseconds", seconds(5)); + test_good("5000 millisecond", seconds(5)); + test_good("5 milliseconds", nanoseconds(5000000)); + std::cout << __LINE__<< "*****" << std::endl; + test_good("4000 ms", seconds(4)); + std::cout << __LINE__<< "*****" << std::endl; + test_fail("3001 ms", seconds(3)); + std::cout << __LINE__<< "*****" << std::endl; + test_fail("3001 ", milliseconds(3001)); + std::cout << __LINE__<< "*****" << std::endl; + test_fail("one ms", milliseconds(1)); + test_fail("5000 millisecon", seconds(5)); + test_not_eof("3001 ms ", milliseconds(3001)); + + return boost::report_errors(); + +} + diff --git a/src/boost/libs/chrono/test/io/duration_output.cpp b/src/boost/libs/chrono/test/io/duration_output.cpp new file mode 100644 index 00000000..e8113153 --- /dev/null +++ b/src/boost/libs/chrono/test/io/duration_output.cpp @@ -0,0 +1,114 @@ +// Copyright 2011 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 test_good_prefix(const char* str, D d) +{ + std::ostringstream out; + out << d; + BOOST_TEST(out.good()); + + BOOST_TEST(out.str() == str); +} + +template +void test_good_symbol(const char* str, D d) +{ + std::ostringstream out; +#if BOOST_CHRONO_VERSION==2 + out << boost::chrono::duration_fmt(boost::chrono::duration_style::symbol) << d; +#else + out << boost::chrono::duration_short << d; +#endif + BOOST_TEST(out.good()); + BOOST_TEST_EQ(out.str(), str); +} +#if BOOST_CHRONO_VERSION==2 + +template +void test_good(const char* str, D d, boost::chrono::duration_style style) +{ + std::ostringstream out; + + out << boost::chrono::duration_fmt(style) << d; + BOOST_TEST(out.good()); + BOOST_TEST(out.str() == str); +} + +template +void test_state_saver(const char* str, const char* str2, D d, boost::chrono::duration_style style) +{ + std::ostringstream out; + { + boost::chrono::duration_style_io_saver ios(out); + out << boost::chrono::duration_fmt(style) << d; + BOOST_TEST(out.good()); + BOOST_TEST(out.str() == str); + } + out << " " << d; + BOOST_TEST(out.good()); + BOOST_TEST(out.str() == str2); +} + +template +void test_state_saver2(const char* str, const char* str2, D d, boost::chrono::duration_style style) +{ + std::ostringstream out; + { + boost::chrono::duration_style_io_saver ios(out, style); + out << d; + BOOST_TEST(out.good()); + BOOST_TEST(out.str() == str); + } + out << " " << d; + BOOST_TEST(out.good()); + BOOST_TEST(out.str() == str2); +} + +#endif + +int main() +{ + using namespace boost::chrono; + using namespace boost; + + test_good_prefix("5000 hours", hours(5000)); + test_good_prefix("5000 minutes", minutes(5000)); + test_good_prefix("5000 seconds", seconds(5000)); + test_good_prefix("0 seconds", seconds(0)); + test_good_prefix("1 second", seconds(1)); + test_good_prefix("-1 second", seconds(-1)); + test_good_prefix("5000 milliseconds", milliseconds(5000)); + test_good_prefix("5000 microseconds", microseconds(5000)); + test_good_prefix("5000 nanoseconds", nanoseconds(5000)); + test_good_prefix("5000 deciseconds", duration (5000)); + test_good_prefix("5000 [1/30]seconds", duration > (5000)); + + test_good_symbol("5000 h", hours(5000)); +#if BOOST_CHRONO_VERSION==2 + test_good_symbol("5000 min", minutes(5000)); +#else + test_good_symbol("5000 m", minutes(5000)); +#endif + test_good_symbol("5000 s", seconds(5000)); + test_good_symbol("5000 ms", milliseconds(5000)); + test_good_symbol("5000 ns", nanoseconds(5000)); + test_good_symbol("5000 ds", duration (5000)); + test_good_symbol("5000 [1/30]s", duration > (5000)); + +#if BOOST_CHRONO_VERSION==2 + test_good("5000 hours", hours(5000), duration_style::prefix); + test_good("5000 h", hours(5000), duration_style::symbol); + test_state_saver("5000 h", "5000 h 5000 hours", hours(5000), duration_style::symbol); + test_state_saver2("5000 h", "5000 h 5000 hours", hours(5000), duration_style::symbol); +#endif + + return boost::report_errors(); + +} + diff --git a/src/boost/libs/chrono/test/io/time_point_input.cpp b/src/boost/libs/chrono/test/io/time_point_input.cpp new file mode 100644 index 00000000..7f0e9348 --- /dev/null +++ b/src/boost/libs/chrono/test/io/time_point_input.cpp @@ -0,0 +1,238 @@ +// Copyright 2011 Vicente J. Botet Escriba +// Copyright (c) Microsoft Corporation 2014 +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include +#include +#if 0 +template +void test_good(std::string str, D res) +{ + typedef typename Clock::time_point clock_time_point; + typedef typename Clock::duration clock_duration; + std::istringstream in(str + boost::chrono::clock_string::since()); + clock_time_point tp; + in >> tp; + BOOST_TEST(in.eof()); + BOOST_TEST(!in.fail()); + std::cout << "Input= " << str << std::endl; + std::cout << "Expected= " << clock_time_point(boost::chrono::duration_cast(res)) << std::endl; + std::cout << "Obtained= " << tp << std::endl; + BOOST_TEST( (tp == clock_time_point(boost::chrono::duration_cast(res)) )); +} + +#else +template +void test_good(std::string str, D res) +{ + typedef boost::chrono::time_point clock_time_point; + //typedef typename Clock::duration clock_duration; + std::istringstream in(str + boost::chrono::clock_string::since()); + clock_time_point tp; + in >> tp; + BOOST_TEST(in.eof()); + BOOST_TEST(!in.fail()); + std::cout << "Input= " << str << std::endl; + std::cout << "Expected= " << clock_time_point(res) << std::endl; + std::cout << "Obtained= " << tp << std::endl; + BOOST_TEST( tp == clock_time_point(res) ); +} + +#endif +#if BOOST_CHRONO_VERSION >= 2 +template +void test_good_system_clock(std::string str, D res) +{ + typedef boost::chrono::system_clock Clock; + + std::istringstream in(str); + boost::chrono::time_point tp; + in >> tp; + BOOST_TEST(in.eof()); + BOOST_TEST(!in.fail()); + std::cout << "Input= " << str << std::endl; + std::cout << "Expected= " << boost::chrono::time_point(res) << std::endl; + std::cout << "Obtained= " << tp << std::endl; + std::cout << "Expected= " << boost::chrono::duration_cast(boost::chrono::time_point(res).time_since_epoch()).count() << std::endl; + std::cout << "Obtained= " << boost::chrono::duration_cast(tp.time_since_epoch()).count() << std::endl; + BOOST_TEST( (tp == boost::chrono::time_point(res))); +} + +template +void test_good_utc_fmt_system_clock(std::string str, std::string fmt, D res) +{ + typedef boost::chrono::system_clock Clock; + + std::istringstream in(str); + boost::chrono::time_point tp; + in >> time_fmt(boost::chrono::timezone::utc, fmt); + in >> tp; + BOOST_TEST(in.eof()); + BOOST_TEST(!in.fail()); + std::cout << "Input= " << str << std::endl; + std::cout << "Expected= " << boost::chrono::time_point(res) << std::endl; + std::cout << "Obtained= " << tp << std::endl; + std::cout << "Expected= " << boost::chrono::duration_cast(boost::chrono::time_point(res).time_since_epoch()).count() << std::endl; + std::cout << "Obtained= " << boost::chrono::duration_cast(tp.time_since_epoch()).count() << std::endl; + BOOST_TEST_EQ( tp , (boost::chrono::time_point(res))); +} +#endif +template +void test_fail(const char* str, D) +{ + std::istringstream in(str + boost::chrono::clock_string::since()); + boost::chrono::time_point tp; + in >> tp; + BOOST_TEST(in.fail()); + BOOST_TEST( (tp == boost::chrono::time_point())); +} + +template +void test_fail_no_epoch(const char* str, D ) +{ + std::istringstream in(str); + boost::chrono::time_point tp; + in >> tp; + BOOST_TEST(in.fail()); + BOOST_TEST( (tp == boost::chrono::time_point())); +} + +template +void test_fail_epoch(const char* str, D) +{ + std::istringstream in(str); + boost::chrono::time_point tp; + in >> tp; + BOOST_TEST(in.fail()); + BOOST_TEST( (tp == boost::chrono::time_point())); +} + +template +void check_all() +{ + using namespace boost::chrono; + using namespace boost; + + test_good ("5000 hours", hours(5000)); + test_good ("5000 minutes", minutes(5000)); + test_good ("5000 seconds", seconds(5000)); + test_good ("1 seconds", seconds(1)); + test_good ("1 second", seconds(1)); + test_good ("-1 seconds", seconds(-1)); + test_good ("0 second", seconds(0)); + test_good ("0 seconds", seconds(0)); + test_good ("5000 milliseconds", milliseconds(5000)); + test_good ("5000 microseconds", microseconds(5000)); + test_good ("5000 nanoseconds", nanoseconds(5000)); + test_good ("5000 deciseconds", duration (5000)); + test_good ("5000 [1/30]seconds", duration > (5000)); + + test_good ("5000 h", hours(5000)); +#if BOOST_CHRONO_VERSION >= 2 + test_good("5000 min", minutes(5000)); +#else + test_good ("5000 m", minutes(5000)); +#endif + test_good ("5000 s", seconds(5000)); + test_good ("5000 ms", milliseconds(5000)); + test_good ("5000 ns", nanoseconds(5000)); + test_good ("5000 ds", duration (5000)); + test_good ("5000 [1/30]s", duration > (5000)); + + test_good ("5000 milliseconds", seconds(5)); + test_good ("5 milliseconds", nanoseconds(5000000)); + test_good ("4000 ms", seconds(4)); + test_fail ("3001 ms", seconds(3)); + test_fail_epoch ("3001 ms", seconds(3)); + test_fail_epoch ("3001 ms since", seconds(3)); + +} + +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP +void check_all_process_cpu_clock() +{ + using namespace boost::chrono; + using namespace boost; + //typedef process_cpu_clock Clock; + //test_good ("{5000;0;0} nanoseconds", process_cpu_clock::duration(process_cpu_clock::times(5000,0,0))); +} +#endif + +#if BOOST_CHRONO_VERSION >= 2 +void check_all_system_clock() +{ + using namespace boost::chrono; + using namespace boost; + + test_good_system_clock ("1970-01-01 02:00:00.000000 +0000", hours(2)); + test_good_system_clock ("1970-07-28 08:00:00.000000 +0000", hours(5000)); + test_good_system_clock ("1970-01-04 11:20:00.000000 +0000", minutes(5000)); + test_good_system_clock ("1970-01-01 01:23:20.000000 +0000", seconds(5000)); + test_good_system_clock ("1970-01-01 00:00:01.000000 +0000", seconds(1)); + test_good_system_clock ("1970-01-01 00:00:01.000000 +0000", seconds(1)); + test_good_system_clock ("1969-12-31 23:59:59.000000 +0000", seconds(-1)); + test_good_system_clock ("1970-01-01 00:00:00.000000 +0000", seconds(0)); + test_good_system_clock ("1970-01-01 00:00:00.000000 +0000", seconds(0)); + test_good_system_clock ("1970-01-01 00:00:05.000000 +0000", milliseconds(5000)); + test_good_system_clock ("1970-01-01 00:00:00.005000 +0000", microseconds(5000)); + test_good_system_clock ("1970-01-01 00:00:00.000005 +0000", nanoseconds(5000)); + test_good_system_clock ("1970-01-01 00:08:20.000000 +0000", duration (5000)); + test_good_system_clock ("1970-01-01 00:02:46.666667 +0000", duration > (5000)); + + test_good_utc_fmt_system_clock ("1970-01-01 02:00:00", "%Y-%m-%d %H:%M:%S", hours(2)); + test_good_utc_fmt_system_clock ("1970-01-01 02:00:00", "%F %H:%M:%S", hours(2)); + test_good_utc_fmt_system_clock ("1970-01-01 02", "%Y-%m-%d %H", hours(2)); + test_good_utc_fmt_system_clock ("1970-01-01 02", "%F %H", hours(2)); + test_good_utc_fmt_system_clock ("1970-01-01 02:00:00", "%Y-%m-%d %T", hours(2)); + test_good_utc_fmt_system_clock ("1970-01-01 02:00", "%Y-%m-%d %R", hours(2)); + test_good_utc_fmt_system_clock ("% 1970-01-01 02:00", "%% %Y-%m-%d %R", hours(2)); + //test_good_utc_fmt_system_clock ("1970-01-01 02:00 Thursday January", "%Y-%m-%d %R %A %B", hours(2)); + + +// test_fail ("3001 ms", seconds(3)); +// test_fail_epoch ("3001 ms", seconds(3)); +// test_fail_epoch ("3001 ms since", seconds(3)); + +} +#endif +int main() +{ + std::cout << "high_resolution_clock=" << std::endl; + check_all (); +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + std::cout << "steady_clock=" << std::endl; + check_all (); +#endif + std::cout << "system_clock=" << std::endl; +#if BOOST_CHRONO_VERSION >= 2 && defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT + check_all_system_clock(); +#else + check_all (); +#endif +#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK) + std::cout << "thread_clock="<< std::endl; + check_all(); +#endif + +#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS) + std::cout << "process_real_cpu_clock=" << std::endl; + check_all (); +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP + std::cout << "process_user_cpu_clock=" << std::endl; + check_all (); + std::cout << "process_system_cpu_clock=" << std::endl; + check_all (); + std::cout << "process_cpu_clock=" << std::endl; + //check_all_process_cpu_clock(); +#endif +#endif + + return boost::report_errors(); + +} + diff --git a/src/boost/libs/chrono/test/io/time_point_output.cpp b/src/boost/libs/chrono/test/io/time_point_output.cpp new file mode 100644 index 00000000..6d5b021b --- /dev/null +++ b/src/boost/libs/chrono/test/io/time_point_output.cpp @@ -0,0 +1,317 @@ +// Copyright 2011 Vicente J. Botet Escriba +// Copyright (c) Microsoft Corporation 2014 +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +void test_good_prefix(const char* str, D d) +{ + std::ostringstream out; + boost::chrono::time_point tp(d); + out << tp; + BOOST_TEST(out.good()); + //std::cout << "Expected= " << std::string(str) + boost::chrono::clock_string::since() << std::endl; + //std::cout << "Obtained= " << out.str() << std::endl; + BOOST_TEST( (out.str() == std::string(str) + boost::chrono::clock_string::since())); +} + +template +void test_good_prefix_system_clock(const char* str, D d) +{ + typedef boost::chrono::system_clock Clock; + + std::ostringstream out; + boost::chrono::time_point tp(d); + out << tp; + BOOST_TEST(out.good()); + + std::cout << "Expected= " << str << std::endl; + std::cout << "Obtained= " << out.str() << std::endl; + BOOST_TEST( (out.str() == std::string(str) )); +} + +template +void test_good_symbol(const char* str, D d) +{ + std::ostringstream out; + boost::chrono::time_point tp(d); +#if BOOST_CHRONO_VERSION>=2 + out << boost::chrono::duration_fmt(boost::chrono::duration_style::symbol) << tp; +#else + out << boost::chrono::duration_short << tp; +#endif + BOOST_TEST(out.good()); + BOOST_TEST( (out.str() == std::string(str) + boost::chrono::clock_string::since())); +} + +#if BOOST_CHRONO_VERSION>=2 +template +void test_good_symbol_system_clock(const char* str, D d) +{ + typedef boost::chrono::system_clock Clock; + + std::ostringstream out; + boost::chrono::time_point tp(d); + out << boost::chrono::duration_fmt(boost::chrono::duration_style::symbol) << tp; + BOOST_TEST(out.good()); + std::cout << "Expected= " << str << std::endl; + std::cout << "Obtained= " << out.str() << std::endl; + BOOST_TEST( (out.str() == std::string(str) )); +} + +template +void test_good_utc_fmt_system_clock(const char* str, const char* fmt, D d) +{ + typedef boost::chrono::system_clock Clock; + + std::ostringstream out; + boost::chrono::time_point tp(d); + boost::chrono::time_fmt_io_saver<> fmts(out); + boost::chrono::timezone_io_saver tzs(out); + out << time_fmt(boost::chrono::timezone::utc, fmt) << tp; + BOOST_TEST(out.good()); + std::cout << "Expected= " << str << std::endl; + std::cout << "Obtained= " << out.str() << std::endl; + BOOST_TEST_EQ( out.str() , std::string(str) ); +} + +template +void test_good_utc_fmt_system_clock2(const char* str, const char* fmt, D d) +{ + typedef boost::chrono::system_clock Clock; + + std::ostringstream out; + boost::chrono::time_point tp(d); + boost::chrono::time_fmt_io_saver<> fmts(out, fmt); + boost::chrono::timezone_io_saver tzs(out, boost::chrono::timezone::utc); + out << tp; + BOOST_TEST(out.good()); + std::cout << "Expected= " << str << std::endl; + std::cout << "Obtained= " << out.str() << std::endl; + BOOST_TEST_EQ( out.str() , std::string(str) ); +} + +template +void test_good(const char* str, D d, boost::chrono::duration_style style) +{ + std::ostringstream out; + boost::chrono::time_point tp(d); + out << boost::chrono::duration_fmt(style) << tp; + BOOST_TEST(out.good()); + BOOST_TEST((out.str() == std::string(str)+boost::chrono::clock_string::since())); +} + +template +void test_good_system_clock(const char* str, D d, boost::chrono::duration_style style) +{ + typedef boost::chrono::system_clock Clock; + + std::ostringstream out; + boost::chrono::time_point tp(d); + out << boost::chrono::duration_fmt(style) << tp; + BOOST_TEST(out.good()); + std::cout << "Expected= " << str << std::endl; + std::cout << "Obtained= " << out.str() << std::endl; + BOOST_TEST((out.str() == std::string(str) )); +} +#endif + +template +void check_all() +{ + using namespace boost::chrono; + using namespace boost; + +#if BOOST_CHRONO_VERSION>=2 + test_good("2 hours", hours(2), duration_style::prefix); + test_good("2 h", hours(2), duration_style::symbol); +#endif + + test_good_prefix ("2 hours", hours(2)); + test_good_prefix ("2 minutes", minutes(2)); + test_good_prefix ("2 seconds", seconds(2)); + test_good_prefix ("1 second", seconds(1)); + test_good_prefix ("-1 second", seconds(-1)); + test_good_prefix ("0 seconds", seconds(0)); + test_good_prefix ("2 milliseconds", milliseconds(2)); + test_good_prefix ("2 microseconds", microseconds(2)); + test_good_prefix ("2 nanoseconds", nanoseconds(2)); + test_good_prefix ("2 deciseconds", duration (2)); + test_good_prefix ("2 [1/30]seconds", duration > (2)); + + test_good_symbol ("2 h", hours(2)); +#if BOOST_CHRONO_VERSION>=2 + test_good_symbol("2 min", minutes(2)); +#else + test_good_symbol ("2 m", minutes(2)); +#endif + test_good_symbol ("2 s", seconds(2)); + test_good_symbol ("2 ms", milliseconds(2)); + test_good_symbol ("2 ns", nanoseconds(2)); + test_good_symbol ("2 ds", duration (2)); + test_good_symbol ("2 [1/30]s", duration > (2)); +} + +#if BOOST_CHRONO_VERSION >= 2 +void check_all_system_clock() +{ + using namespace boost::chrono; + using namespace boost; + + test_good_system_clock("1970-01-01 02:00:00.000000000 +0000", hours(2), duration_style::prefix); + test_good_system_clock("1970-01-01 02:00:00.000000000 +0000", hours(2), duration_style::symbol); + + test_good_prefix_system_clock("1970-01-01 02:00:00.000000000 +0000", hours(2)); + test_good_prefix_system_clock("1970-01-01 00:02:00.000000000 +0000", minutes(2)); + test_good_prefix_system_clock("1970-01-01 00:00:02.000000000 +0000", seconds(2)); + test_good_prefix_system_clock("1970-01-01 00:00:01.000000000 +0000", seconds(1)); + test_good_prefix_system_clock("1969-12-31 23:59:59.000000000 +0000", seconds(-1)); + test_good_prefix_system_clock("1970-01-01 00:00:00.000000000 +0000", seconds(0)); + test_good_prefix_system_clock("1970-01-01 00:00:00.002000000 +0000", milliseconds(2)); + test_good_prefix_system_clock("1970-01-01 00:00:00.000002000 +0000", microseconds(2)); + test_good_prefix_system_clock("1970-01-01 00:00:00.000000002 +0000", nanoseconds(2)); + test_good_prefix_system_clock("1970-01-01 00:00:00.200000000 +0000", duration (2)); + test_good_prefix_system_clock("1970-01-01 00:00:00.066666667 +0000", duration > (2)); + + test_good_symbol_system_clock("1970-01-01 02:00:00.000000000 +0000", hours(2)); + test_good_symbol_system_clock("1970-01-01 00:02:00.000000000 +0000", minutes(2)); + test_good_symbol_system_clock("1970-01-01 00:00:02.000000000 +0000", seconds(2)); + test_good_symbol_system_clock("1970-01-01 00:00:00.002000000 +0000", milliseconds(2)); + test_good_symbol_system_clock("1970-01-01 00:00:00.000000002 +0000", nanoseconds(2)); + test_good_symbol_system_clock("1970-01-01 00:00:00.200000000 +0000", duration (2)); + test_good_symbol_system_clock("1970-01-01 00:00:00.066666667 +0000", duration > (2)); + + test_good_utc_fmt_system_clock("1970-01-01 02:00:00", "%Y-%m-%d %H:%M:%S", hours(2)); + test_good_utc_fmt_system_clock("1970-01-01 02", "%Y-%m-%d %H", hours(2)); +#if ! defined(BOOST_CHRONO_WINDOWS_API) + test_good_utc_fmt_system_clock ("1970-01-01 02:00:00", "%Y-%m-%d %T", hours(2)); + test_good_utc_fmt_system_clock ("1970-01-01 02:00", "%Y-%m-%d %R", hours(2)); + test_good_utc_fmt_system_clock ("% 1970-01-01 02:00", "%% %Y-%m-%d %R", hours(2)); + test_good_utc_fmt_system_clock ("1970-01-01 02:00 Thursday January", "%Y-%m-%d %R %A %B", hours(2)); +#endif + test_good_utc_fmt_system_clock2("1970-01-01 02:00:00", "%Y-%m-%d %H:%M:%S", hours(2)); + test_good_utc_fmt_system_clock2("1970-01-01 02", "%Y-%m-%d %H", hours(2)); +#if ! defined(BOOST_CHRONO_WINDOWS_API) + test_good_utc_fmt_system_clock2 ("1970-01-01 02:00:00", "%Y-%m-%d %T", hours(2)); + test_good_utc_fmt_system_clock2 ("1970-01-01 02:00", "%Y-%m-%d %R", hours(2)); + test_good_utc_fmt_system_clock2 ("% 1970-01-01 02:00", "%% %Y-%m-%d %R", hours(2)); + test_good_utc_fmt_system_clock2 ("1970-01-01 02:00 Thursday January", "%Y-%m-%d %R %A %B", hours(2)); +#endif +} + + +#endif +#if defined BOOST_CHRONO_INTERNAL_GMTIME +#elif BOOST_CHRONO_VERSION == 2 +void test_gmtime(std::time_t t) +{ + std::cout << "t " << t << std::endl; + std::puts(ctime(&t)); + std::tm tm; + std::memset(&tm, 0, sizeof(std::tm)); + if (boost::chrono::detail::internal_gmtime(&t, &tm)) + { + tm.tm_isdst = -1; + (void)mktime(&tm); + std::tm tm2; + std::memset(&tm2, 0, sizeof(std::tm)); + if (gmtime_r(&t, &tm2)) + { + tm2.tm_isdst = -1; + (void)mktime(&tm2); + + BOOST_TEST_EQ( tm.tm_year , tm2.tm_year ); + BOOST_TEST_EQ( tm.tm_mon , tm2.tm_mon ); + BOOST_TEST_EQ( tm.tm_mday , tm2.tm_mday ); + BOOST_TEST_EQ( tm.tm_hour , tm2.tm_hour); + BOOST_TEST_EQ( tm.tm_min , tm2.tm_min ); + BOOST_TEST_EQ( tm.tm_sec , tm2.tm_sec ); + BOOST_TEST_EQ( tm.tm_wday , tm2.tm_wday ); + BOOST_TEST_EQ( tm.tm_yday , tm2.tm_yday ); + BOOST_TEST_EQ( tm.tm_isdst , tm2.tm_isdst ); + } + } + +} +#endif + + +int main() +{ +#if defined BOOST_CHRONO_INTERNAL_GMTIME +#elif BOOST_CHRONO_VERSION == 2 + test_gmtime( 0 ); + test_gmtime( -1 ); + test_gmtime( +1 ); + test_gmtime( 0 - (3600 * 24) ); + test_gmtime( -1 - (3600 * 24) ); + test_gmtime( +1 - (3600 * 24) ); + test_gmtime( 0 + (3600 * 24) ); + test_gmtime( -1 + (3600 * 24) ); + test_gmtime( +1 + (3600 * 24) ); + test_gmtime( 0 + 365*(3600 * 24) ); + test_gmtime( 0 + 10LL*365*(3600 * 24) ); + test_gmtime( 0 + 15LL*365*(3600 * 24) ); + test_gmtime( 0 + 17LL*365*(3600 * 24) ); + test_gmtime( 0 + 18LL*365*(3600 * 24) ); + test_gmtime( 0 + 19LL*365*(3600 * 24) ); + test_gmtime( 0 + 19LL*365*(3600 * 24)+ (3600 * 24)); + test_gmtime( 0 + 19LL*365*(3600 * 24)+ 3*(3600 * 24)); + test_gmtime( 0 + 19LL*365*(3600 * 24)+ 4*(3600 * 24)); + test_gmtime( 0 + 20LL*365*(3600 * 24) ); + test_gmtime( 0 + 40LL*365*(3600 * 24) ); +#endif + + std::cout << "high_resolution_clock=" << std::endl; + check_all (); +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + std::cout << "steady_clock=" << std::endl; + check_all (); +#endif + std::cout << "system_clock=" << std::endl; +#if BOOST_CHRONO_VERSION >= 2 && defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT + check_all_system_clock(); +#else + check_all (); +#endif + +#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK) + std::cout << "thread_clock="<< std::endl; + check_all(); +#endif + +#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS) + std::cout << "process_real_cpu_clock=" << std::endl; + check_all (); +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP + std::cout << "process_user_cpu_clock=" << std::endl; + check_all (); + std::cout << "process_system_cpu_clock=" << std::endl; + check_all (); + std::cout << "process_cpu_clock=" << std::endl; + check_all (); +#endif +#endif + +#if defined BOOST_CHRONO_INTERNAL_GMTIME +#elif BOOST_CHRONO_VERSION == 2 + boost::chrono::system_clock::time_point tp = boost::chrono::system_clock::now(); + std::cout << tp << std::endl; + time_t t = boost::chrono::system_clock::to_time_t(tp); + test_gmtime( t ); +#endif + + return boost::report_errors(); + +} + diff --git a/src/boost/libs/chrono/test/one_obj.cpp b/src/boost/libs/chrono/test/one_obj.cpp new file mode 100644 index 00000000..ed8d61a0 --- /dev/null +++ b/src/boost/libs/chrono/test/one_obj.cpp @@ -0,0 +1,23 @@ +// boost win32_test.cpp -----------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See http://www.boost.org/libs/chrono for documentation. +#include +#include +#include + +void another(); + +int main() +{ + boost::chrono::steady_clock::time_point t1=boost::chrono::steady_clock::now(); + another(); + boost::chrono::steady_clock::time_point t2=boost::chrono::steady_clock::now(); + std::cout << t2-t1 << std::endl; + return 0; +} + diff --git a/src/boost/libs/chrono/test/rep.h b/src/boost/libs/chrono/test/rep.h new file mode 100644 index 00000000..b7e4ca27 --- /dev/null +++ b/src/boost/libs/chrono/test/rep.h @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +#ifndef REP_H +#define REP_H + +#include + +class Rep +{ +public: + int data_; + BOOST_CONSTEXPR Rep() : data_() {} + explicit BOOST_CONSTEXPR Rep(int i) : data_(i) {} + + BOOST_CONSTEXPR bool operator==(int i) const {return data_ == i;} + BOOST_CONSTEXPR bool operator==(const Rep& r) const {return data_ == r.data_;} + + Rep& operator*=(Rep x) {data_ *= x.data_; return *this;} + Rep& operator/=(Rep x) {data_ /= x.data_; return *this;} +}; + +#if 0 +namespace std { + + template <> + struct numeric_limits + { + static BOOST_CONSTEXPR Rep max BOOST_PREVENT_MACRO_SUBSTITUTION () + { + return Rep((std::numeric_limits::max)()); + } + + }; +} // namespace std + +namespace boost { +namespace chrono { +template <> +struct duration_values +{ + static BOOST_CONSTEXPR Rep zero() {return Rep(0);} + static BOOST_CONSTEXPR Rep max BOOST_PREVENT_MACRO_SUBSTITUTION () + { + return Rep((std::numeric_limits::max)()); + } + + static BOOST_CONSTEXPR Rep min BOOST_PREVENT_MACRO_SUBSTITUTION () + { + return Rep(detail::numeric_limits::lowest()); + } +}; + +} // namespace chrono +} // namespace boost +#endif +#endif // REP_H diff --git a/src/boost/libs/chrono/test/run_timer_test.cpp b/src/boost/libs/chrono/test/run_timer_test.cpp new file mode 100644 index 00000000..0f14a73e --- /dev/null +++ b/src/boost/libs/chrono/test/run_timer_test.cpp @@ -0,0 +1,226 @@ +// boost run_timer_test.cpp -----------------------------------------------------// + +// Copyright Beman Dawes 2006, 2008 +// Copyright 2009 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See http://www.boost.org/libs/chrono for documentation. + +#include +#include +#include // for atol() +#include +#include +#include +#include +#include // for sqrt(), used to burn time + +using boost::chrono::run_timer; +using boost::system::error_code; + +#include + +//#define BOOST_TEST(expr) if (!(expr)) std::cout << "*****ERROR*****\n" + +#define CHECK_REPORT(Timer,String_Stream,R,U,S,Expected_String) \ + check_report(Timer, String_Stream, R, U, S, Expected_String, __LINE__) + + +namespace +{ + typedef boost::chrono::nanoseconds ns; + + bool check_report( run_timer & tmr, std::stringstream & ss, + run_timer::duration r, run_timer::duration u, run_timer::duration s, + const std::string & expected, int line ) + { + tmr.test_report(r,u,s); + bool result(true); + if ( ss.str() != expected ) + { + std::cout << "run_timer_test.cpp(" << line << ") : error: actual output \"" + << ss.str() << "\" != expected \"" << expected << "\"\n"; + result = false; + } + return result; + } + + void run_timer_constructor_overload_test() + { + // exercise each supported combination of constructor arguments + + std::ostream & os = std::cout; + const int pl = 9; + boost::system::error_code ec; + + run_timer t1; + run_timer t2( os ); + run_timer t3( ec ); + run_timer t4( os, ec ); + run_timer t5( pl ); + run_timer t6( os, pl ); + run_timer t7( pl, ec ); + run_timer t8( os, pl, ec ); + run_timer t9( "t9, default places, r %r, c %c, p %p, u %u, s %s\n" ); + run_timer t10( os, "t10, default places, r %r, c %c, p %p, u %u, s %s\n" ); + run_timer t11( "t11, default places, r %r, c %c, p %p, u %u, s %s\n", ec ); + run_timer t12( os, "t12, default places, r %r, c %c, p %p, u %u, s %s\n", ec ); + run_timer t13( pl, "t13, explicitly code places, r %r, c %c, p %p, u %u, s %s\n" ); + run_timer t14( "t14, explicitly code places, r %r, c %c, p %p, u %u, s %s\n", pl ); + run_timer t15( os, pl, "t15, explicitly code places, r %r, c %c, p %p, u %u, s %s\n" ); + run_timer t16( os, "t16, explicitly code places, r %r, c %c, p %p, u %u, s %s\n", pl ); + run_timer t17( pl, "t17, explicitly code places, r %r, c %c, p %p, u %u, s %s\n", ec ); + run_timer t18( "t18, explicitly code places, r %r, c %c, p %p, u %u, s %s\n", pl, ec ); + run_timer t19( os, pl, "t19, explicitly code places, r %r, c %c, p %p, u %u, s %s\n", ec ); + run_timer t20( os, "t20, explicitly code places, r %r, c %c, p %p, u %u, s %s\n", pl, ec ); + + std::cout << "Burn some time so run_timers have something to report..."; + boost::chrono::timer t; + while ( t.elapsed() < boost::chrono::seconds(1) ) {} + std::cout << "\n"; + std::cout << run_timer::default_places() << " default places\n"; + std::cout << pl << " explicitly coded places\n"; + } + + // accuracy test + void accuracy_test( int argc, char * argv[] ) + { + long timeout_in_secs = 1; + if ( argc > 1 ) timeout_in_secs = std::atol( argv[1] ); + std::cout << "accuracy test for " << timeout_in_secs << " second(s)..."; + + std::clock_t timeout_in_clock_t = std::clock(); + timeout_in_clock_t += (timeout_in_secs * CLOCKS_PER_SEC); + + boost::chrono::system_timer sys; +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + boost::chrono::steady_timer mono; +#endif + boost::chrono::high_resolution_timer hires; + boost::chrono::process_timer process; + + std::clock_t now; + do + { + now = std::clock(); + } while ( now < timeout_in_clock_t ); + + boost::chrono::system_timer::duration sys_dur = sys.elapsed(); +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + boost::chrono::steady_timer::duration mono_dur = mono.elapsed(); +#endif + boost::chrono::high_resolution_timer::duration hires_dur = hires.elapsed(); + boost::chrono::process_times times; + process.elapsed( times ); + + std::cout << std::endl; + + ns timeout_in_nanoseconds( static_cast(timeout_in_secs) * 1000000000LL ); + + // Allow 20% leeway. Particularly on Linux, there seems to be a large discrepancy + // between std::clock() and higher resolution clocks. + ns maximum_delta ( static_cast(timeout_in_nanoseconds.count() * 0.20 ) ); + + std::cout << timeout_in_nanoseconds.count() << " timeout_in_nanoseconds\n"; + std::cout << maximum_delta.count() << " maximum_delta\n"; + + std::cout << sys_dur.count() << " sys_dur\n"; + + BOOST_TEST( sys_dur > timeout_in_nanoseconds - maximum_delta + && sys_dur < timeout_in_nanoseconds + maximum_delta ); + +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + std::cout << mono_dur.count() << " mono_dur\n"; + + BOOST_TEST( mono_dur > timeout_in_nanoseconds - maximum_delta + && mono_dur < timeout_in_nanoseconds + maximum_delta ); +#endif + + std::cout << hires_dur.count() << " hires_dur\n"; + + BOOST_TEST( hires_dur > timeout_in_nanoseconds - maximum_delta + && hires_dur < timeout_in_nanoseconds + maximum_delta ); + + std::cout << times.real.count() << " times.real\n"; + + BOOST_TEST( times.real > timeout_in_nanoseconds - maximum_delta + && times.real < timeout_in_nanoseconds + maximum_delta ); + } + + // report test + + void report_test() + { + { + std::stringstream ss; + run_timer t(ss); + BOOST_TEST( CHECK_REPORT(t, ss, ns(0), ns(0), ns(0), + "\nreal 0.000s, cpu 0.000s (0.0%), user 0.000s, system 0.000s\n" ) ); + } + + { + std::stringstream ss; + run_timer t(ss); + BOOST_TEST( CHECK_REPORT(t, ss, ns(3000000000LL), ns(2000000000LL), ns(1000000000LL), + "\nreal 3.000s, cpu 3.000s (100.0%), user 2.000s, system 1.000s\n" ) ); + } + + { + std::stringstream ss; + run_timer t( ss, "9 places: r %r, c %c, p %p, u %u, s %s", 9 ); + BOOST_TEST( CHECK_REPORT(t, ss, ns(3000000003LL), ns(2000000002LL), ns(1000000001LL), + "9 places: " + "r 3.000000003, c 3.000000003, p 100.0, u 2.000000002, s 1.000000001" ) ); + } + } + + // process_timer_test + + void process_timer_test() + { + std::cout << "process_timer_test..." << std::flush; + + boost::chrono::process_timer t; + double res=0; // avoids optimization + for (long i = 0; i < 10000000L; ++i) + { + res+=std::sqrt( static_cast(i) ); // avoids optimization + } + + boost::chrono::process_times times; + times.real = times.system = times.user = ns(0); + + BOOST_TEST( times.real == ns(0) ); + BOOST_TEST( times.user == ns(0) ); + BOOST_TEST( times.system == ns(0) ); + + t.elapsed( times ); + std::cout << "\n"; + + std::cout << times.real.count() << " times.real\n"; + std::cout << times.user.count() << " times.user\n"; + std::cout << times.system.count() << " times.system\n"; + std::cout << (times.user+times.system).count() << " times.user+system\n"; + BOOST_TEST( times.real > ns(1) ); + + BOOST_TEST( times.user+times.system > ns(1) ); + + std::cout << "complete " << res << std::endl; + } +} + +int main( int argc, char * argv[] ) +{ + std::locale loc( "" ); // test with appropriate locale + std::cout.imbue( loc ); + + accuracy_test( argc, argv ); + run_timer_constructor_overload_test(); + process_timer_test(); + report_test(); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/chrono/test/test_10631.cpp b/src/boost/libs/chrono/test/test_10631.cpp new file mode 100644 index 00000000..2bce583b --- /dev/null +++ b/src/boost/libs/chrono/test/test_10631.cpp @@ -0,0 +1,61 @@ +// Copyright 2015 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt +// See http://www.boost.org/libs/chrono for documentation. + +#define BOOST_CHRONO_VERION 2 +#include +#include +#include + +// a custom clock +// here based on boost's own system_clock +class MyMillenniumClock +{ +public: + typedef boost::chrono::system_clock::rep rep; + typedef boost::chrono::system_clock::period period; + typedef boost::chrono::duration duration; + typedef boost::chrono::time_point time_point; + + BOOST_STATIC_CONSTEXPR bool is_steady = boost::chrono::system_clock::is_steady; + +public: + /// Returns a time_point representing the current value of the clock. + static time_point now() { + return time_point(boost::chrono::system_clock::now().time_since_epoch() - boost::chrono::hours(30*365)); + } +}; + + +namespace boost +{ + namespace chrono + { + template + struct clock_string + { + static std::basic_string name() { + static const CharT a[] = {'M', 'y', 'M', 'i', 'l', 'l', 'e', 'n', 'n', 'i', 'u', 'm', 'C', 'l', 'o', 'c', 'k'}; + return std::basic_string(a, a + sizeof(a)/sizeof(a[0])); + } + static std::basic_string since() { + static const CharT a[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'y', 'e', 'a', 'r', ' ', '2', 'k'}; + return std::basic_string(a, a + sizeof(a)/sizeof(a[0])); + } + }; + } +} + +template +std::basic_string get_epoch_custom(MyMillenniumClock, TPUFacet&) +{ + return boost::chrono::clock_string::since(); +} + +int main() +{ + std::cout << boost::chrono::steady_clock::now() << std::endl; + std::cout << MyMillenniumClock::now() << std::endl; + return 0; +} diff --git a/src/boost/libs/chrono/test/test_10778.cpp b/src/boost/libs/chrono/test/test_10778.cpp new file mode 100644 index 00000000..7693cd3f --- /dev/null +++ b/src/boost/libs/chrono/test/test_10778.cpp @@ -0,0 +1,19 @@ +// Copyright 2015 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt +// See http://www.boost.org/libs/chrono for documentation. + +//#define BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 +#include +#include +#include + +void test() +{ + std::atomic ms; // error C2338: atomic requires T to be trivially copyable. +} + +int main() { + test(); + return 1; +} diff --git a/src/boost/libs/chrono/test/test_11006.cpp b/src/boost/libs/chrono/test/test_11006.cpp new file mode 100644 index 00000000..cf40fc05 --- /dev/null +++ b/src/boost/libs/chrono/test/test_11006.cpp @@ -0,0 +1,21 @@ +// Copyright 2015 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt +// See http://www.boost.org/libs/chrono for documentation. + +//#define BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 +#define BOOST_CHRONO_VERSION 2 +#include +#include + + +int main() { + { + boost::chrono::time_fmt_io_saver<> tmp(std::cout); + } + { + boost::chrono::time_fmt_io_saver<> tmp(std::cout, "%Y-%m-%d %H:%M:%S"); + } + return 0; +} + diff --git a/src/boost/libs/chrono/test/test_11012.cpp b/src/boost/libs/chrono/test/test_11012.cpp new file mode 100644 index 00000000..249b9b89 --- /dev/null +++ b/src/boost/libs/chrono/test/test_11012.cpp @@ -0,0 +1,27 @@ +// Copyright 2015 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt +// See http://www.boost.org/libs/chrono for documentation. + +//#define BOOST_CHRONO_VERSION 1 +#define BOOST_CHRONO_VERSION 2 +#include +#include +#include +//#define BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 +#include + +int main() +{ + { + typedef boost::chrono::duration RationalSeconds; + RationalSeconds d(0.5); + std::cout << d << std::endl; + } + { + typedef boost::chrono::duration > RationalSeconds; + RationalSeconds d; + std::cout << d << std::endl; + } + return 0; +} diff --git a/src/boost/libs/chrono/test/test_12176.cpp b/src/boost/libs/chrono/test/test_12176.cpp new file mode 100644 index 00000000..253d88a1 --- /dev/null +++ b/src/boost/libs/chrono/test/test_12176.cpp @@ -0,0 +1,11 @@ +// Copyright 2016 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt +// See http://www.boost.org/libs/chrono for documentation. + +#include + +int main() +{ + return 0; +} diff --git a/src/boost/libs/chrono/test/test_7868.cpp b/src/boost/libs/chrono/test/test_7868.cpp new file mode 100644 index 00000000..38f658b8 --- /dev/null +++ b/src/boost/libs/chrono/test/test_7868.cpp @@ -0,0 +1,81 @@ +// Copyright 2013 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt +// See http://www.boost.org/libs/chrono for documentation. + +#define BOOST_CHRONO_VERSION 2 +//#define BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT 1 + +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + using namespace boost; + using namespace boost::chrono; + boost::chrono::system_clock::time_point atnow= boost::chrono::system_clock::now(); + { + std::stringstream strm; + std::stringstream strm2; + // does not change anything: strm<>atnow2; + strm2<(atnow2 - atnow).count() <(atnow2 - atnow).count(), 0); + std::stringstream formatted; + formatted << time_fmt(boost::chrono::timezone::utc, "%Y-%m-%d %H:%M:%S"); + formatted << "actual:"<< atnow <>atnow2; + strm2<(atnow2 - atnow).count(), 0); + + } + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/test_9337.cpp b/src/boost/libs/chrono/test/test_9337.cpp new file mode 100644 index 00000000..9f3dd7e0 --- /dev/null +++ b/src/boost/libs/chrono/test/test_9337.cpp @@ -0,0 +1,27 @@ +//#define BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 +#include +#include +#include +#include + +using namespace std; +using namespace boost::chrono; + +template +void test() +{ + typename Clock::time_point start=Clock::now(); + sleep(1); + typename Clock::time_point stop=Clock::now(); + cout<(); + test(); + test(); + test(); + return 1; +} diff --git a/src/boost/libs/chrono/test/time_point/arithmetic_ext_pass.cpp b/src/boost/libs/chrono/test/time_point/arithmetic_ext_pass.cpp new file mode 100644 index 00000000..6543ac1e --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/arithmetic_ext_pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +#define BOOST_CHRONO_EXTENSIONS +#include +#include +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +int main() +{ + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t += 2; + BOOST_TEST(t.time_since_epoch() == Duration(5)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t++; + BOOST_TEST(t.time_since_epoch() == Duration(4)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + ++t; + BOOST_TEST(t.time_since_epoch() == Duration(4)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t -= 2; + BOOST_TEST(t.time_since_epoch() == Duration(1)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t--; + BOOST_TEST(t.time_since_epoch() == Duration(2)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + --t; + BOOST_TEST(t.time_since_epoch() == Duration(2)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/time_point/arithmetic_pass.cpp b/src/boost/libs/chrono/test/time_point/arithmetic_pass.cpp new file mode 100644 index 00000000..3cfe2e1f --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/arithmetic_pass.cpp @@ -0,0 +1,151 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +int main() +{ + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t += Duration(2); + BOOST_TEST(t.time_since_epoch() == Duration(5)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t -= Duration(2); + BOOST_TEST(t.time_since_epoch() == Duration(1)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + boost::chrono::time_point t1(Duration1(3)); + boost::chrono::time_point t2 = t1 - Duration2(5); + BOOST_TEST(t2.time_since_epoch() == Duration2(2995)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + BOOST_CONSTEXPR boost::chrono::time_point t1(Duration1(3)); + BOOST_CONSTEXPR boost::chrono::time_point t2 = t1 - Duration2(5); + BOOST_CONSTEXPR_ASSERT(t2.time_since_epoch() == Duration2(2995)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + boost::chrono::time_point t1(Duration1(3)); + boost::chrono::time_point t2(Duration2(5)); + BOOST_TEST( (t1 - t2) == Duration2(2995)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + BOOST_CONSTEXPR boost::chrono::time_point t1(Duration1(3)); + BOOST_CONSTEXPR boost::chrono::time_point t2(Duration2(5)); + BOOST_CONSTEXPR_ASSERT( (t1 - t2) == Duration2(2995)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + boost::chrono::time_point t1(Duration1(3)); + boost::chrono::time_point t2 = t1 + Duration2(5); + BOOST_TEST(t2.time_since_epoch() == Duration2(3005)); + t2 = Duration2(6) + t1; + BOOST_TEST(t2.time_since_epoch() == Duration2(3006)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + BOOST_CONSTEXPR boost::chrono::time_point t1(Duration1(3)); + BOOST_CONSTEXPR boost::chrono::time_point t2 = t1 + Duration2(5); + BOOST_CONSTEXPR_ASSERT(t2.time_since_epoch() == Duration2(3005)); + BOOST_CONSTEXPR boost::chrono::time_point t3 = Duration2(6) + t1; + BOOST_CONSTEXPR_ASSERT(t3.time_since_epoch() == Duration2(3006)); + } +#ifdef BOOST_CHRONO_EXTENSIONS + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t += 2; + BOOST_TEST(t.time_since_epoch() == Duration(5)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t++; + BOOST_TEST(t.time_since_epoch() == Duration(4)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + ++t; + BOOST_TEST(t.time_since_epoch() == Duration(4)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + t -= 2; + BOOST_TEST(t.time_since_epoch() == Duration(1)); + } +#if 0 + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + boost::chrono::time_point t1(Duration1(3)); + boost::chrono::time_point t2 = t1 - Duration2(5); + BOOST_TEST(t2.time_since_epoch() == Duration2(2995)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + boost::chrono::time_point t1(Duration1(3)); + boost::chrono::time_point t2(Duration2(5)); + BOOST_TEST((t1 - t2) == Duration2(2995)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + boost::chrono::time_point t1(Duration1(3)); + boost::chrono::time_point t2 = t1 + Duration2(5); + BOOST_TEST(t2.time_since_epoch() == Duration2(3005)); + t2 = Duration2(6) + t1; + BOOST_TEST(t2.time_since_epoch() == Duration2(3006)); + } +#endif +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/time_point/comparisons/equal_fail.cpp b/src/boost/libs/chrono/test/time_point/comparisons/equal_fail.cpp new file mode 100644 index 00000000..39327377 --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/comparisons/equal_fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// time_points with different clocks should not compare + +#include + +#include "../../clock.h" + +void test() +{ + typedef boost::chrono::system_clock Clock1; + typedef Clock Clock2; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + typedef boost::chrono::time_point T1; + typedef boost::chrono::time_point T2; + + T1 t1(Duration1(3)); + T2 t2(Duration2(3000)); + t1 == t2; +} diff --git a/src/boost/libs/chrono/test/time_point/comparisons/less_fail.cpp b/src/boost/libs/chrono/test/time_point/comparisons/less_fail.cpp new file mode 100644 index 00000000..de88234f --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/comparisons/less_fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// time_points with different clocks should not compare + +#include + +#include "../../clock.h" + +void test() +{ + typedef boost::chrono::system_clock Clock1; + typedef Clock Clock2; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + typedef boost::chrono::time_point T1; + typedef boost::chrono::time_point T2; + + T1 t1(Duration1(3)); + T2 t2(Duration2(3000)); + t1 < t2; +} diff --git a/src/boost/libs/chrono/test/time_point/comparisons_pass.cpp b/src/boost/libs/chrono/test/time_point/comparisons_pass.cpp new file mode 100644 index 00000000..b361c979 --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/comparisons_pass.cpp @@ -0,0 +1,146 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + + +int main() +{ + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + typedef boost::chrono::time_point T1; + typedef boost::chrono::time_point T2; + + { + T1 t1(Duration1(3)); + T1 t2(Duration1(3)); + BOOST_TEST( (t1 == t2)); + BOOST_TEST(! (t1 != t2)); + } + { + BOOST_CONSTEXPR T1 t1(Duration1(3)); + BOOST_CONSTEXPR T1 t2(Duration1(3)); + BOOST_CONSTEXPR_ASSERT( (t1 == t2)); + BOOST_CONSTEXPR_ASSERT(! (t1 != t2)); + } + { + T1 t1(Duration1(3)); + T1 t2(Duration1(4)); + BOOST_TEST(! (t1 == t2)); + BOOST_TEST( (t1 != t2)); + } + { + BOOST_CONSTEXPR T1 t1(Duration1(3)); + BOOST_CONSTEXPR T1 t2(Duration1(4)); + BOOST_CONSTEXPR_ASSERT(! (t1 == t2)); + BOOST_CONSTEXPR_ASSERT( (t1 != t2)); + } + { + T1 t1(Duration1(3)); + T2 t2(Duration2(3000)); + BOOST_TEST( (t1 == t2)); + BOOST_TEST(! (t1 != t2)); + } + { + BOOST_CONSTEXPR T1 t1(Duration1(3)); + BOOST_CONSTEXPR T2 t2(Duration2(3000)); + BOOST_CONSTEXPR_ASSERT( (t1 == t2)); + BOOST_CONSTEXPR_ASSERT(! (t1 != t2)); + } + { + T1 t1(Duration1(3)); + T2 t2(Duration2(3001)); + BOOST_TEST(! (t1 == t2)); + BOOST_TEST( (t1 != t2)); + } + { + BOOST_CONSTEXPR T1 t1(Duration1(3)); + BOOST_CONSTEXPR T2 t2(Duration2(3001)); + BOOST_CONSTEXPR_ASSERT(! (t1 == t2)); + BOOST_CONSTEXPR_ASSERT( (t1 != t2)); + } + { + T1 t1(Duration1(3)); + T1 t2(Duration1(3)); + BOOST_TEST(! (t1 < t2)); + BOOST_TEST(! (t1 > t2)); + BOOST_TEST( (t1 <= t2)); + BOOST_TEST( (t1 >= t2)); + } + { + BOOST_CONSTEXPR T1 t1(Duration1(3)); + BOOST_CONSTEXPR T1 t2(Duration1(3)); + BOOST_CONSTEXPR_ASSERT(! (t1 < t2)); + BOOST_CONSTEXPR_ASSERT(! (t1 > t2)); + BOOST_CONSTEXPR_ASSERT( (t1 <= t2)); + BOOST_CONSTEXPR_ASSERT( (t1 >= t2)); + } + { + T1 t1(Duration1(3)); + T1 t2(Duration1(4)); + BOOST_TEST( (t1 < t2)); + BOOST_TEST(! (t1 > t2)); + BOOST_TEST( (t1 <= t2)); + BOOST_TEST(! (t1 >= t2)); + } + { + BOOST_CONSTEXPR T1 t1(Duration1(3)); + BOOST_CONSTEXPR T1 t2(Duration1(4)); + BOOST_CONSTEXPR_ASSERT( (t1 < t2)); + BOOST_CONSTEXPR_ASSERT(! (t1 > t2)); + BOOST_CONSTEXPR_ASSERT( (t1 <= t2)); + BOOST_CONSTEXPR_ASSERT(! (t1 >= t2)); + } + { + T1 t1(Duration1(3)); + T2 t2(Duration2(3000)); + BOOST_TEST(! (t1 < t2)); + BOOST_TEST(! (t1 > t2)); + BOOST_TEST( (t1 <= t2)); + BOOST_TEST( (t1 >= t2)); + } + { + BOOST_CONSTEXPR T1 t1(Duration1(3)); + BOOST_CONSTEXPR T2 t2(Duration2(3000)); + BOOST_CONSTEXPR_ASSERT(! (t1 < t2)); + BOOST_CONSTEXPR_ASSERT(! (t1 > t2)); + BOOST_CONSTEXPR_ASSERT( (t1 <= t2)); + BOOST_CONSTEXPR_ASSERT( (t1 >= t2)); + } + { + T1 t1(Duration1(3)); + T2 t2(Duration2(3001)); + BOOST_TEST( (t1 < t2)); + BOOST_TEST(! (t1 > t2)); + BOOST_TEST( (t1 <= t2)); + BOOST_TEST(! (t1 >= t2)); + } + { + BOOST_CONSTEXPR T1 t1(Duration1(3)); + BOOST_CONSTEXPR T2 t2(Duration2(3001)); + BOOST_CONSTEXPR_ASSERT( (t1 < t2)); + BOOST_CONSTEXPR_ASSERT(! (t1 > t2)); + BOOST_CONSTEXPR_ASSERT( (t1 <= t2)); + BOOST_CONSTEXPR_ASSERT(! (t1 >= t2)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/time_point/cons/implicit_fail.cpp b/src/boost/libs/chrono/test/time_point/cons/implicit_fail.cpp new file mode 100644 index 00000000..616ca7e1 --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/cons/implicit_fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// test for explicit + +#include + +void test() +{ + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t = Duration(3); +} diff --git a/src/boost/libs/chrono/test/time_point/cons/non_implicit_convertible_duration_fail.cpp b/src/boost/libs/chrono/test/time_point/cons/non_implicit_convertible_duration_fail.cpp new file mode 100644 index 00000000..520ca4d7 --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/cons/non_implicit_convertible_duration_fail.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// Duration2 shall be implicitly convertible to duration. + +#include + +void test() +{ + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration1; + typedef boost::chrono::microseconds Duration2; + { + boost::chrono::time_point t2(Duration2(3)); + boost::chrono::time_point t1 = t2; + } +} diff --git a/src/boost/libs/chrono/test/time_point/constructor_pass.cpp b/src/boost/libs/chrono/test/time_point/constructor_pass.cpp new file mode 100644 index 00000000..62a6ed6b --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/constructor_pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// 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 "../rep.h" +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +int main() +{ + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::microseconds Duration1; + typedef boost::chrono::milliseconds Duration2; + boost::chrono::time_point t2(Duration2(3)); + boost::chrono::time_point t1 = t2; + BOOST_TEST(t1.time_since_epoch() == Duration1(3000)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::microseconds Duration1; + typedef boost::chrono::milliseconds Duration2; + BOOST_CONSTEXPR boost::chrono::time_point t2(Duration2(3)); + BOOST_CONSTEXPR boost::chrono::time_point t1 = t2; + BOOST_CONSTEXPR_ASSERT(t1.time_since_epoch() == Duration1(3000)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::duration Duration; + boost::chrono::time_point t; + BOOST_TEST(t.time_since_epoch() == Duration::zero()); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::duration Duration; + BOOST_CONSTEXPR boost::chrono::time_point t; + BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration::zero()); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(Duration(3)); + BOOST_TEST(t.time_since_epoch() == Duration(3)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + BOOST_CONSTEXPR boost::chrono::time_point t(Duration(3)); + BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration(3)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + boost::chrono::time_point t(boost::chrono::seconds(3)); + BOOST_TEST(t.time_since_epoch() == Duration(3000)); + } + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + BOOST_CONSTEXPR boost::chrono::time_point t(boost::chrono::seconds(3)); + BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration(3000)); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/time_point/default_duration.pass.cpp b/src/boost/libs/chrono/test/time_point/default_duration.pass.cpp new file mode 100644 index 00000000..f816b28f --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/default_duration.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +void test() +{ + BOOST_CHRONO_STATIC_ASSERT((boost::is_same::duration>::value), NOTHING, ()); +} diff --git a/src/boost/libs/chrono/test/time_point/default_duration_pass.cpp b/src/boost/libs/chrono/test/time_point/default_duration_pass.cpp new file mode 100644 index 00000000..f816b28f --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/default_duration_pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +void test() +{ + BOOST_CHRONO_STATIC_ASSERT((boost::is_same::duration>::value), NOTHING, ()); +} diff --git a/src/boost/libs/chrono/test/time_point/duration.fail.cpp b/src/boost/libs/chrono/test/time_point/duration.fail.cpp new file mode 100644 index 00000000..b48f48e4 --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/duration.fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// Duration shall be an instance of duration. + +#include + +void test() +{ + typedef boost::chrono::time_point T; + T t; +} diff --git a/src/boost/libs/chrono/test/time_point/min_max_pass.cpp b/src/boost/libs/chrono/test/time_point/min_max_pass.cpp new file mode 100644 index 00000000..74926bdd --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/min_max_pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +#if defined BOOST_NO_CXX11_NUMERIC_LIMITS || defined BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +int main() +{ + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::milliseconds Duration; + typedef boost::chrono::time_point TP; + + BOOST_CONSTEXPR_ASSERT((TP::min)() == TP((Duration::min)())); + BOOST_CONSTEXPR_ASSERT((TP::max)() == TP((Duration::max)())); + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/time_point/not_duration_fail.cpp b/src/boost/libs/chrono/test/time_point/not_duration_fail.cpp new file mode 100644 index 00000000..b48f48e4 --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/not_duration_fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// Duration shall be an instance of duration. + +#include + +void test() +{ + typedef boost::chrono::time_point T; + T t; +} diff --git a/src/boost/libs/chrono/test/time_point/time_point_cast_int_fail.cpp b/src/boost/libs/chrono/test/time_point/time_point_cast_int_fail.cpp new file mode 100644 index 00000000..bf16f9a2 --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/time_point_cast_int_fail.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// ToDuration shall be an instantiation of duration. + +#include + +void test() +{ + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::time_point FromTimePoint; + typedef boost::chrono::time_point ToTimePoint; + boost::chrono::time_point_cast(FromTimePoint(boost::chrono::milliseconds(3))); +} diff --git a/src/boost/libs/chrono/test/time_point/time_point_cast_pass.cpp b/src/boost/libs/chrono/test/time_point/time_point_cast_pass.cpp new file mode 100644 index 00000000..133f94c8 --- /dev/null +++ b/src/boost/libs/chrono/test/time_point/time_point_cast_pass.cpp @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif +#ifdef BOOST_NO_CXX11_CONSTEXPR +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C) +#else +#include +#define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C) +#endif + +template +void +test(const FromDuration& df, const ToDuration& d) +{ + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::time_point FromTimePoint; + typedef boost::chrono::time_point ToTimePoint; + FromTimePoint f(df); + ToTimePoint t(d); +//~ #if defined(BOOST_NO_CXX11_DECLTYPE) + //~ typedef BOOST_TYPEOF_TPL(boost::chrono::time_point_cast(f)) R; +//~ #else + //~ typedef decltype(boost::chrono::time_point_cast(f)) R; +//~ #endif + //~ BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, ()); + BOOST_TEST(boost::chrono::time_point_cast(f) == t); +} + +int main() +{ + test(boost::chrono::milliseconds(7265000), boost::chrono::hours(2)); + test(boost::chrono::milliseconds(7265000), boost::chrono::minutes(121)); + test(boost::chrono::milliseconds(7265000), boost::chrono::seconds(7265)); + test(boost::chrono::milliseconds(7265000), boost::chrono::milliseconds(7265000)); + test(boost::chrono::milliseconds(7265000), boost::chrono::microseconds(7265000000LL)); + test(boost::chrono::milliseconds(7265000), boost::chrono::nanoseconds(7265000000000LL)); + test(boost::chrono::milliseconds(7265000), + boost::chrono::duration >(7265./3600)); + test(boost::chrono::duration >(9), + boost::chrono::duration >(10)); + { + typedef boost::chrono::system_clock Clock; + typedef boost::chrono::time_point FromTimePoint; + typedef boost::chrono::time_point ToTimePoint; + BOOST_CONSTEXPR FromTimePoint f(boost::chrono::milliseconds(7265000)); + BOOST_CONSTEXPR ToTimePoint tph = boost::chrono::time_point_cast(f); + BOOST_CONSTEXPR_ASSERT(tph.time_since_epoch().count() == 2); + } + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/traits/common_type_duration_pass.cpp b/src/boost/libs/chrono/test/traits/common_type_duration_pass.cpp new file mode 100644 index 00000000..f976635e --- /dev/null +++ b/src/boost/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 +#include + +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +template +void +test() +{ + typedef typename boost::common_type::type Dc; + BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, (D1, D2, Dc, De)); +} + +void testall() +{ + test >, + boost::chrono::duration >, + boost::chrono::duration > >(); + test >, + boost::chrono::duration >, + boost::chrono::duration > >(); + test >, + boost::chrono::duration >, + boost::chrono::duration > >(); + test >, + boost::chrono::duration >, + boost::chrono::duration > >(); +} diff --git a/src/boost/libs/chrono/test/traits/common_type_time_point_pass.cpp b/src/boost/libs/chrono/test/traits/common_type_time_point_pass.cpp new file mode 100644 index 00000000..047f7ff0 --- /dev/null +++ b/src/boost/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 +#include + +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +template +void +test() +{ + typedef boost::chrono::system_clock C; + typedef boost::chrono::time_point T1; + typedef boost::chrono::time_point T2; + typedef boost::chrono::time_point Te; + typedef typename boost::common_type::type Tc; + BOOST_CHRONO_STATIC_ASSERT((boost::is_same::value), NOTHING, (T1, T2, Tc, Te)); +} + +void testall() +{ + test >, + boost::chrono::duration >, + boost::chrono::duration > >(); + test >, + boost::chrono::duration >, + boost::chrono::duration > >(); + test >, + boost::chrono::duration >, + boost::chrono::duration > >(); + test >, + boost::chrono::duration >, + boost::chrono::duration > >(); +} diff --git a/src/boost/libs/chrono/test/traits/duration_values_pass.cpp b/src/boost/libs/chrono/test/traits/duration_values_pass.cpp new file mode 100644 index 00000000..9d2c0793 --- /dev/null +++ b/src/boost/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 +#include +#include +#include + +#include "../rep.h" + +int main() +{ + BOOST_TEST((boost::chrono::duration_values::min)() == + (std::numeric_limits::min)()); + BOOST_TEST((boost::chrono::duration_values::min)() == + -(std::numeric_limits::max)()); + BOOST_TEST((boost::chrono::duration_values::min)() == + (std::numeric_limits::min)()); + + BOOST_TEST((boost::chrono::duration_values::max)() == + (std::numeric_limits::max)()); + BOOST_TEST((boost::chrono::duration_values::max)() == + (std::numeric_limits::max)()); + BOOST_TEST((boost::chrono::duration_values::max)() == + (std::numeric_limits::max)()); + + BOOST_TEST(boost::chrono::duration_values::zero() == 0); + BOOST_TEST(boost::chrono::duration_values::zero() == 0); + + return boost::report_errors(); +} diff --git a/src/boost/libs/chrono/test/traits/treat_as_floating_point_pass.cpp b/src/boost/libs/chrono/test/traits/treat_as_floating_point_pass.cpp new file mode 100644 index 00000000..6acd8ed7 --- /dev/null +++ b/src/boost/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 +#include + +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +template +void +test() +{ + BOOST_CHRONO_STATIC_ASSERT((boost::is_base_of, + boost::chrono::treat_as_floating_point >::value), NOTHING, ()); +} + +struct A {}; + +void testall() +{ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} diff --git a/src/boost/libs/chrono/test/win32_test.cpp b/src/boost/libs/chrono/test/win32_test.cpp new file mode 100644 index 00000000..8790f69f --- /dev/null +++ b/src/boost/libs/chrono/test/win32_test.cpp @@ -0,0 +1,149 @@ +// boost win32_test.cpp -----------------------------------------------------// + +// Copyright 2010 Vicente J. Botet Escriba + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See http://www.boost.org/libs/chrono for documentation. +#include +#include +#if defined(BOOST_CHRONO_WINDOWS_API) || defined(__CYGWIN__) + +#include +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) +#define NOTHING "" +#endif + +#include +#include +#undef BOOST_USE_WINDOWS_H +#include +#include +#include + +void test() { + { + boost::winapi::LARGE_INTEGER_ a; + LARGE_INTEGER b; + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::LARGE_INTEGER_)==sizeof(LARGE_INTEGER) + ), NOTHING, (boost::winapi::LARGE_INTEGER_, LARGE_INTEGER)); + BOOST_TEST(( + sizeof(a.QuadPart)==sizeof(b.QuadPart) + )); + BOOST_CHRONO_STATIC_ASSERT(( + offsetof(boost::winapi::LARGE_INTEGER_, QuadPart)==offsetof(LARGE_INTEGER, QuadPart) + ), NOTHING, (boost::winapi::LARGE_INTEGER_, LARGE_INTEGER)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same< + BOOST_TYPEOF(a.QuadPart), + BOOST_TYPEOF(b.QuadPart) + >::value + ), NOTHING, (boost::winapi::LARGE_INTEGER_, LARGE_INTEGER)); + } + + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::BOOL_)==sizeof(BOOL) + ), NOTHING, (boost::winapi::BOOL_, BOOL)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same::value + ), NOTHING, (boost::winapi::BOOL_, BOOL)); + + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::DWORD_)==sizeof(DWORD) + ), NOTHING, (boost::winapi::DWORD_, DWORD)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same::value + ), NOTHING, (boost::winapi::DWORD_, DWORD)); + + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::HANDLE_)==sizeof(HANDLE) + ), NOTHING, (boost::winapi::HANDLE_, HANDLE)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same::value + ), NOTHING, (boost::winapi::HANDLE_, HANDLE)); + + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::LONG_)==sizeof(LONG) + ), NOTHING, (boost::winapi::LONG_, LONG)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same::value + ), NOTHING, (boost::winapi::LONG_, LONG)); + + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::LONGLONG_)==sizeof(LONGLONG) + ), NOTHING, (boost::winapi::LONGLONG_, LONGLONG)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same::value + ), NOTHING, (boost::winapi::LONGLONG_, LONGLONG)); + + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::ULONG_PTR_)==sizeof(ULONG_PTR) + ), NOTHING, (boost::winapi::ULONG_PTR_, ULONG_PTR)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same::value + ), NOTHING, (boost::winapi::ULONG_PTR_, ULONG_PTR)); + + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::PLARGE_INTEGER_)==sizeof(PLARGE_INTEGER) + ), NOTHING, (boost::winapi::PLARGE_INTEGER_, PLARGE_INTEGER)); + //~ BOOST_CHRONO_STATIC_ASSERT(( + //~ boost::is_same::value + //~ ), NOTHING, (boost::winapi::PLARGE_INTEGER_, PLARGE_INTEGER)); + + { + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::FILETIME_)==sizeof(FILETIME) + ), NOTHING, (boost::winapi::FILETIME_, FILETIME)); + + BOOST_CHRONO_STATIC_ASSERT(( + sizeof(boost::winapi::PFILETIME_)==sizeof(PFILETIME) + ), NOTHING, (boost::winapi::PFILETIME_, PFILETIME)); + + + boost::winapi::FILETIME_ a; + FILETIME b; + BOOST_TEST(( + sizeof(a.dwLowDateTime)==sizeof(b.dwLowDateTime) + )); + BOOST_TEST(( + sizeof(a.dwHighDateTime)==sizeof(b.dwHighDateTime) + )); + BOOST_CHRONO_STATIC_ASSERT(( + offsetof(boost::winapi::FILETIME_, dwLowDateTime)==offsetof(FILETIME, dwLowDateTime) + ), NOTHING, (boost::winapi::FILETIME_, FILETIME)); + BOOST_CHRONO_STATIC_ASSERT(( + offsetof(boost::winapi::FILETIME_, dwHighDateTime)==offsetof(FILETIME, dwHighDateTime) + ), NOTHING, (boost::winapi::FILETIME_, FILETIME)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same< + BOOST_TYPEOF(a.dwLowDateTime), + BOOST_TYPEOF(b.dwLowDateTime) + >::value + ), NOTHING, (boost::winapi::FILETIME_, FILETIME)); + BOOST_CHRONO_STATIC_ASSERT(( + boost::is_same< + BOOST_TYPEOF(a.dwHighDateTime), + BOOST_TYPEOF(b.dwHighDateTime) + >::value + ), NOTHING, (boost::winapi::FILETIME_, FILETIME)); + + } + +// BOOST_CHRONO_STATIC_ASSERT(( +// GetLastError==boost::winapi::::GetLastError +// ), NOTHING, ()); + +} +#else +void test() { +} +#endif +int main( ) +{ + test(); + + return boost::report_errors(); +} + -- cgit v1.2.3