summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINMarkus <markus.hossner@innovative-navigation.de>2016-02-23 11:39:20 +0100
committerINMarkus <markus.hossner@innovative-navigation.de>2016-02-23 11:39:20 +0100
commit58100d3aeae33252ad12446f620382734e8f02d2 (patch)
treef783dcd1de87f020a72d0591fa9cadbd3da1ff9d
parent5f2fcf252b7b9790a2cb27e57f9d90ae7ea32f9e (diff)
downloadATCD-58100d3aeae33252ad12446f620382734e8f02d2.tar.gz
Update Time_Value_Test.cpp
Added tests for setting of double values and to check performance of normalize for large numbers.
-rw-r--r--ACE/tests/Time_Value_Test.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/ACE/tests/Time_Value_Test.cpp b/ACE/tests/Time_Value_Test.cpp
index 5806d67179f..04ec4b3f553 100644
--- a/ACE/tests/Time_Value_Test.cpp
+++ b/ACE/tests/Time_Value_Test.cpp
@@ -115,6 +115,51 @@ run_main (int, ACE_TCHAR *[])
ACE_TEXT ("msec const test failed: %Q should be 42555\n"),
ms));
+ // Test setting double values
+ ACE_Time_Value d1(10, 500000);
+ ACE_Time_Value d2;
+ d2.set(10.5);
+
+ ACE_Time_Value d3(-10, -500000);
+ ACE_Time_Value d4;
+ d4.set(-10.5);
+
+ ACE_TEST_ASSERT (d1 == d2);
+ ACE_TEST_ASSERT (d3 == d4);
+ ACE_TEST_ASSERT (d1 + d3 == ACE_Time_Value::zero);
+ ACE_TEST_ASSERT (d3 + d1 == ACE_Time_Value::zero);
+ ACE_TEST_ASSERT (d2 + d4 == ACE_Time_Value::zero);
+ ACE_TEST_ASSERT (d4 + d2 == ACE_Time_Value::zero);
+ ACE_TEST_ASSERT (ACE_Time_Value::zero - d1 = d3);
+ ACE_TEST_ASSERT (ACE_Time_Value::zero - d3 = d1);
+ ACE_TEST_ASSERT (ACE_Time_Value::zero - d2 = d4);
+ ACE_TEST_ASSERT (ACE_Time_Value::zero - d4 = d2);
+
+ ACE_Time_Value d5;
+ d5.set(DBL_MAX);
+ ACE_TEST_ASSERT (d5 == ACE_Time_Value::max_time);
+
+ // Test performance of normalize()
+ ACE_Time_Value v1(ACE_Numeric_Limits<time_t>::max(),
+ ACE_Numeric_Limits<suseconds_t>::max());
+ ACE_Time_Value v2(ACE_Numeric_Limits<time_t>::min(),
+ ACE_Numeric_Limits<suseconds_t>::min());
+ ACE_Time_Value v3(ACE_Numeric_Limits<time_t>::max(),
+ ACE_Numeric_Limits<suseconds_t>::min());
+ ACE_Time_Value v4(ACE_Numeric_Limits<time_t>::min(),
+ ACE_Numeric_Limits<suseconds_t>::max());
+
+ v1.set(ACE_Numeric_Limits<time_t>::max(),
+ ACE_Numeric_Limits<suseconds_t>::max());
+ v2.set(ACE_Numeric_Limits<time_t>::min(),
+ ACE_Numeric_Limits<suseconds_t>::min());
+ v3.set(ACE_Numeric_Limits<time_t>::max(),
+ ACE_Numeric_Limits<suseconds_t>::min());
+ v4.set(ACE_Numeric_Limits<time_t>::min(),
+ ACE_Numeric_Limits<suseconds_t>::max());
+
+ v1.set(DBL_MAX);
+
// Test setting from ACE_UINT64
ms = 42555;
ACE_Time_Value msec_test3;