2 //=============================================================================
4 * @file Bug_2434_Regression_Test.cpp
6 * This is a simple test of ACE_Time_Value. No command line arguments
7 * are needed to run the test.
9 * @author Prashant Jain <pjain@cs.wustl.edu> and David Levine <levine@cs.wustl.edu>
11 //=============================================================================
13 // Note, for this test the config.h file *must* come first!
14 #include "ace/config-all.h"
16 #include "test_config.h"
18 #include "ace/Time_Value.h"
19 #include "ace/Numeric_Limits.h"
22 run_main (int, ACE_TCHAR
*[])
26 ACE_START_TEST (ACE_TEXT ("Bug_2434_Regression_Test"));
31 const time_t max_time_t
= ACE_Numeric_Limits
<time_t>::max ();
32 const time_t min_time_t
= ACE_Numeric_Limits
<time_t>::min ();
34 // test protection against overflows
35 // ACE_TEST_ASSERT( ACE_Time_Value(max_time_t,ACE_ONE_SECOND_IN_USECS) != ACE_Time_Value(ACE_Numeric_Limits<time_t>::min()) );
37 // test saturated result
38 tv1
.set (max_time_t
- 1, 499999);
39 tv2
.set (max_time_t
, 999999); // ACE_Time_Value::max_time
41 ACE_TEST_ASSERT (tv1
== tv2
);
42 tv1
.set (max_time_t
- 1, 499999);
43 tv2
.set (min_time_t
, -999999);
45 ACE_TEST_ASSERT (tv1
== tv2
);
47 // test results near limits
48 tv1
.set ((max_time_t
>> 1), 499999);
49 tv2
.set ((-(max_time_t
>> 1) << 1), -999998);
51 ACE_TEST_ASSERT (tv1
== tv2
);
52 tv1
.set (max_time_t
>> 1, 499999);
53 tv2
.set (((max_time_t
>> 1) << 1), 999998);
55 ACE_TEST_ASSERT (tv1
== tv2
);