Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / tests / Bug_2434_Regression_Test.cpp
blob34dd7274f575741c800c9c9792975c5ed8561652
2 //=============================================================================
3 /**
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"
17 #include "ace/ACE.h"
18 #include "ace/Time_Value.h"
19 #include "ace/Numeric_Limits.h"
21 int
22 run_main (int, ACE_TCHAR *[])
24 int ret = 0;
26 ACE_START_TEST (ACE_TEXT ("Bug_2434_Regression_Test"));
28 ACE_Time_Value tv1;
29 ACE_Time_Value tv2;
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
40 tv1 *= 10.0;
41 ACE_TEST_ASSERT (tv1 == tv2);
42 tv1.set (max_time_t - 1, 499999);
43 tv2.set (min_time_t, -999999);
44 tv1 *= -10.0;
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);
50 tv1 *= -2.0;
51 ACE_TEST_ASSERT (tv1 == tv2);
52 tv1.set (max_time_t >> 1, 499999);
53 tv2.set (((max_time_t >> 1) << 1), 999998);
54 tv1 *= 2.0;
55 ACE_TEST_ASSERT (tv1 == tv2);
57 ACE_END_TEST;
59 return ret;