1 | /* Copyright (c) 2002,2003 CrystalClear Software, Inc. |
2 | * Use, modification and distribution is subject to the |
3 | * Boost Software License, Version 1.0. (See accompanying |
4 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
5 | * Author: Jeff Garland |
6 | */ |
7 | |
8 | #include "boost/date_time/time_resolution_traits.hpp" |
9 | #include "testfrmwk.hpp" |
10 | |
11 | |
12 | int |
13 | main() |
14 | { |
15 | using namespace boost::date_time; |
16 | check(testname: "milli traits num digits" , testcond: milli_res::num_fractional_digits() == 3); |
17 | check(testname: "milli traits resolution adjust" , |
18 | testcond: milli_res::res_adjust() == 1000); |
19 | check(testname: "milli tick calculations" , |
20 | testcond: milli_res::to_tick_count(hours: 0,minutes: 0,seconds: 0,fs: 1) == 1); |
21 | check(testname: "milli tick calculations" , |
22 | testcond: milli_res::to_tick_count(hours: 0,minutes: 0,seconds: 1,fs: 1) == 1001); |
23 | check(testname: "milli tick calculations" , |
24 | testcond: milli_res::to_tick_count(hours: 0,minutes: 1,seconds: 0,fs: 0) == 60000); |
25 | boost::int64_t one_hour_milli = 3600*1000; |
26 | check(testname: "milli tick calculations" , |
27 | testcond: milli_res::to_tick_count(hours: 1,minutes: 0,seconds: 0,fs: 0) == one_hour_milli); |
28 | |
29 | check(testname: "micro traits num digits" , testcond: micro_res::num_fractional_digits() == 6); |
30 | check(testname: "micro traits resolution adjust" , |
31 | testcond: micro_res::res_adjust() == 1000000); |
32 | check(testname: "micro tick calculations" , |
33 | testcond: micro_res::to_tick_count(hours: 0,minutes: 0,seconds: 0,fs: 1) == 1); |
34 | check(testname: "micro tick calculations" , |
35 | testcond: micro_res::to_tick_count(hours: 0,minutes: 0,seconds: 1,fs: 1) == 1000001); |
36 | check(testname: "micro tick calculations" , |
37 | testcond: micro_res::to_tick_count(hours: 0,minutes: 1,seconds: 0,fs: 0) == 60000000); |
38 | boost::int64_t one_hour_micro = 3600*1000; |
39 | one_hour_micro = one_hour_micro*1000; //avoid compiler overflow! |
40 | check(testname: "micro tick calculations" , |
41 | testcond: micro_res::to_tick_count(hours: 1,minutes: 0,seconds: 0,fs: 0) == one_hour_micro); |
42 | |
43 | check(testname: "nano traits num digits" , testcond: nano_res::num_fractional_digits() == 9); |
44 | check(testname: "nano traits resolution adjust" , |
45 | testcond: nano_res::res_adjust() == 1000000000); |
46 | check(testname: "nano tick calculations" , |
47 | testcond: nano_res::to_tick_count(hours: 0,minutes: 0,seconds: 0,fs: 1) == 1); |
48 | check(testname: "nano tick calculations" , |
49 | testcond: nano_res::to_tick_count(hours: 0,minutes: 0,seconds: 1,fs: 1) == 1000000001); |
50 | boost::int64_t one_minute_nano = 60*1000*1000; |
51 | one_minute_nano = one_minute_nano*1000; |
52 | check(testname: "nano tick calculations" , |
53 | testcond: nano_res::to_tick_count(hours: 0,minutes: 1,seconds: 0,fs: 0) == one_minute_nano); |
54 | |
55 | //skip io on VC6 b/c of lack of operator<< for int64 |
56 | #if (defined(BOOST_MSVC) && (_MSC_VER < 1300)) |
57 | #else |
58 | std::cout << one_hour_micro << std::endl; |
59 | #endif |
60 | boost::int64_t one_hour_nano = one_hour_micro*1000; |
61 | #if (defined(BOOST_MSVC) && (_MSC_VER < 1300)) |
62 | #else |
63 | std::cout << one_hour_nano << std::endl; |
64 | #endif |
65 | check(testname: "nano tick calculations" , |
66 | testcond: nano_res::to_tick_count(hours: 1,minutes: 0,seconds: 0,fs: 0) == one_hour_nano); |
67 | |
68 | |
69 | return printTestStats(); |
70 | |
71 | } |
72 | |
73 | |