diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2007-02-27 21:23:18 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2007-02-27 21:23:18 +0000 |
commit | f1ab97a7579b4f4e0f32269e50535d7f45aa3c22 (patch) | |
tree | 30baad133df71c71e222958231e73861416344ad | |
parent | 9e5d9c8ee9f96b73cf881677279bf603484f90b2 (diff) | |
download | ATCD-f1ab97a7579b4f4e0f32269e50535d7f45aa3c22.tar.gz |
ChangeLogTag:Tue Feb 27 21:18:07 UTC 2007 Ossama Othman <ossama_othman at symantec dot com>
-rw-r--r-- | ACE/ChangeLog | 13 | ||||
-rw-r--r-- | ACE/tests/CDR_File_Test.cpp | 20 | ||||
-rw-r--r-- | ACE/tests/High_Res_Timer_Test.cpp | 80 | ||||
-rw-r--r-- | ACE/tests/Integer_Truncate_Test.cpp | 34 |
4 files changed, 82 insertions, 65 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 19e86e339d7..b40b67999fb 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,16 @@ +Tue Feb 27 21:18:07 UTC 2007 Ossama Othman <ossama_othman at symantec dot com> + + * tests/Integer_Truncate_Test.cpp: + * tests/CDR_File_Test.cpp: + + s/ACE_Utils::Truncate/ACE_Utils::truncate_cast/g. The former is + deprecated. + + * tests/High_Res_Timer_Test.cpp: + + Improved variable types to make use of + ACE_Utils::truncate_cast<> unnecessary. + Tue Feb 27 18:55:12 UTC 2007 Iliyan Jeliazkov <iliyan@ociweb.com> * ace/CDR_Stream.cpp: diff --git a/ACE/tests/CDR_File_Test.cpp b/ACE/tests/CDR_File_Test.cpp index 92f92631073..6aeb97a5e7b 100644 --- a/ACE/tests/CDR_File_Test.cpp +++ b/ACE/tests/CDR_File_Test.cpp @@ -27,6 +27,7 @@ #include "ace/Auto_Ptr.h" #include "ace/Get_Opt.h" #include "ace/ACE.h" +#include "ace/Truncate.h" // FUZZ: disable check_for_streams_include #include "ace/streams.h" @@ -87,9 +88,11 @@ operator << (ostream &os, ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n" "Char: %c\n" - "Short: %u\n" + "Short: %u\n" "Long: %d\n"), - t.char_, t.word2_, t.word4_)); + t.char_, + t.word2_, + t.word4_)); ACE_CDR::ULongLong hi = (t.word8_ >> 32); ACE_CDR::ULongLong lo = (t.word8_ & 0xffffffff); @@ -97,12 +100,13 @@ operator << (ostream &os, ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n" "ULongLong 1st half: %x\n" - "ULongLong 2nd half: %x\n" + "ULongLong 2nd half: %x\n" "Float: %f\n" "Double: %f\n"), - ACE_U64_TO_U32(hi), - ACE_U64_TO_U32(lo), - t.fpoint_, t.dprec_)); + ACE_Utils::truncate_cast<ACE_UINT32> (hi), + ACE_Utils::truncate_cast<ACE_UINT32> (lo), + t.fpoint_, + t.dprec_)); #else os << "Char: " << t.char_ << endl << "Short: " << t.word2_ << endl @@ -113,11 +117,11 @@ operator << (ostream &os, os << "ULongLong 1st half: " << hex - << ACE_U64_TO_U32 (hi) + << ACE_Utils::truncate_cast<ACE_UINT32> (hi) << dec << endl << "ULongLong 2nd half: " << hex - << ACE_U64_TO_U32 (lo) + << ACE_Utils::truncate_cast<ACE_UINT32> (lo) << dec << endl << "Float: " << t.fpoint_ << endl << "Double: " << t.dprec_ << endl; diff --git a/ACE/tests/High_Res_Timer_Test.cpp b/ACE/tests/High_Res_Timer_Test.cpp index 5d0bf60f7fb..df39d9f94c4 100644 --- a/ACE/tests/High_Res_Timer_Test.cpp +++ b/ACE/tests/High_Res_Timer_Test.cpp @@ -21,7 +21,6 @@ #include "ace/Sched_Params.h" #include "ace/Get_Opt.h" #include "ace/OS_NS_unistd.h" -#include "ace/Truncate.h" ACE_RCSID(tests, High_Res_Timer_Test, "High_Res_Timer_Test.cpp,v 4.6 2000/04/23 04:43:58 brunsch Exp") @@ -29,22 +28,21 @@ static u_int check (const time_t interval, const time_t measured) { - const u_int threshold = 25 /* percent */; + time_t const threshold = 25 /* percent */; - const time_t difference = + time_t const difference = interval > measured ? interval - measured : measured - interval; - const u_int percentage_difference - = ACE_Utils::Truncate<u_int> (difference * 100 / interval); + time_t const percentage_difference = difference * 100 / interval; if (percentage_difference < threshold) return 0; else ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("The measured time of %u differs from ") - ACE_TEXT ("the interval of %u by %u percent.\n"), - ACE_Utils::Truncate<u_int> (measured), - ACE_Utils::Truncate<u_int> (interval), + ACE_TEXT ("The measured time of %Q differs from ") + ACE_TEXT ("the interval of %Q by %Q percent.\n"), + measured, + interval, percentage_difference), 1); } @@ -54,26 +52,26 @@ check (const time_t interval, const time_t measured) static u_int check_micro_nano (ACE_hrtime_t microinterval, ACE_hrtime_t nanointerval) { - const u_int threshold = 8 /* promille */; + ACE_hrtime_t const threshold = 8 /* promille */; microinterval *= 1000u; - ACE_hrtime_t hr_difference = (microinterval > nanointerval ? - microinterval - nanointerval : - nanointerval - microinterval ); - const u_int difference = ACE_Utils::Truncate<u_int> (hr_difference); + ACE_hrtime_t const difference = (microinterval > nanointerval + ? (microinterval - nanointerval) + : (nanointerval - microinterval)); if (nanointerval == 0) nanointerval = 1; // Prevent divide-by-zero - const u_int promille_difference = difference * 1000 / - ACE_Utils::Truncate<u_int>(nanointerval); + ACE_hrtime_t const promille_difference = + difference * 1000 / nanointerval; if ((promille_difference < threshold) || (difference < 1500)) return 0; else ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("The microseconds * 1000 of %u differs from ") - ACE_TEXT ("the nanoseconds of %u by %u promille\n"), - ACE_Utils::Truncate<u_int> (microinterval), - ACE_Utils::Truncate<u_int> (nanointerval), + ACE_TEXT ("The microseconds * 1000 of %Q ") + ACE_TEXT ("differs from the nanoseconds of %Q ") + ACE_TEXT (" by %Q promille\n"), + microinterval, + nanointerval, promille_difference), 1); } @@ -98,9 +96,8 @@ time_interval (const ACE_Time_Value &interval, } -static -u_int -intervals [] = {0, 1, 10, 100, 1000, 10000, 100000, 1000000, 4000000}; /*usec*/ +static u_int const intervals[] = + {0, 1, 10, 100, 1000, 10000, 100000, 1000000, 4000000}; /*usec*/ int run_main (int argc, ACE_TCHAR *argv[]) @@ -127,7 +124,7 @@ run_main (int argc, ACE_TCHAR *argv[]) // We don't check for errors if the interval is shorter than this // value because the OS has a finite resolution anyway. - const u_int TIMER_RESOLUTION = 10000; + static u_int const TIMER_RESOLUTION = 10000; for (u_int i = 0; i < sizeof intervals / sizeof (u_int); ++i) { @@ -139,38 +136,41 @@ run_main (int argc, ACE_TCHAR *argv[]) const ACE_Time_Value measured = time_interval (interval, nanoseconds, microseconds); - u_int interval_usec = - ACE_Utils::Truncate<u_int> (interval.sec () * 1000000 + interval.usec ()); - u_int measured_usec = - ACE_Utils::Truncate<u_int> (measured.sec () * 1000000 + measured.usec ()); + time_t const interval_usec = + interval.sec () * ACE_ONE_SECOND_IN_USECS + interval.usec (); + time_t const measured_usec = + measured.sec () * ACE_ONE_SECOND_IN_USECS + measured.usec (); + ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("interval: %u usec, measured: %u usec%s\n"), + ACE_TEXT ("interval: %Q usec, measured: %Q usec %s\n"), interval_usec, measured_usec, - intervals[i] <= TIMER_RESOLUTION ? - ACE_TEXT (" (interval and measured may differ)") : - ACE_TEXT (""))); + (intervals[i] <= TIMER_RESOLUTION + ? ACE_TEXT (" (interval and measured may differ)") + : ACE_TEXT ("")))); if (intervals[i] > TIMER_RESOLUTION) { - errors += check (interval.sec () * 1000000 + interval.usec (), - measured.sec () * 1000000 + measured.usec ()); + errors += check (interval.sec () * ACE_ONE_SECOND_IN_USECS + + interval.usec (), + measured.sec () * ACE_ONE_SECOND_IN_USECS + + measured.usec ()); // Don't check for error for intervals below 10 msec. } // Check the ACE_Timer_Value-calculated microseconds against // the ACE_High_Res_Timer-calculated nanoseconds. ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE_Time_Value usec: %u, ACE_HR nsec: %u\n"), + ACE_TEXT ("ACE_Time_Value usec: %Q, ACE_HR nsec: %Q\n"), measured_usec, - ACE_Utils::Truncate<u_int> (nanoseconds))); + nanoseconds)); // This gives problems -> should be fixed - errors += check_micro_nano (measured.sec () * 1000000 + errors += check_micro_nano (measured.sec () * ACE_ONE_SECOND_IN_USECS + measured.usec (), nanoseconds); ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ACE_High_Res_Timer usec: %u, nsec: %u\n"), - ACE_Utils::Truncate<u_int> (microseconds), - ACE_Utils::Truncate<u_int> (nanoseconds))); + ACE_TEXT ("ACE_High_Res_Timer usec: %Q, nsec: %Q\n"), + microseconds, + nanoseconds)); // Now check the ACE_High_Res_Timer-calculated values against // each other. errors += check_micro_nano (microseconds, nanoseconds); diff --git a/ACE/tests/Integer_Truncate_Test.cpp b/ACE/tests/Integer_Truncate_Test.cpp index f9c60764bca..97f08a10d03 100644 --- a/ACE/tests/Integer_Truncate_Test.cpp +++ b/ACE/tests/Integer_Truncate_Test.cpp @@ -4,7 +4,7 @@ * * $Id$ * - * Test @c ACE_Utils::Truncate<> function template. + * Test @c ACE_Utils::truncate_cast<> function template. * * @author Ossama Othman <ossama_othman at symantec dot com> */ @@ -40,7 +40,7 @@ sizeof_from_lt_sizeof_to (void) from_type f = ACE_Numeric_Limits<from_type>::max (); // Should not be truncated. - if (Truncate<to_type> (f) != static_cast<to_type> (f)) + if (truncate_cast<to_type> (f) != static_cast<to_type> (f)) { success = false; @@ -60,7 +60,7 @@ sizeof_from_lt_sizeof_to (void) from_type f = ACE_Numeric_Limits<from_type>::max (); // Should not be truncated. - if (Truncate<to_type> (f) != static_cast<to_type> (f)) + if (truncate_cast<to_type> (f) != static_cast<to_type> (f)) { success = false; @@ -81,8 +81,8 @@ sizeof_from_lt_sizeof_to (void) from_type f2 = ACE_Numeric_Limits<from_type>::max (); // Should not be truncated. - if (Truncate<to_type> (f1) != f1 - || Truncate<to_type> (f2) != f2) + if (truncate_cast<to_type> (f1) != f1 + || truncate_cast<to_type> (f2) != f2) { success = false; @@ -102,7 +102,7 @@ sizeof_from_lt_sizeof_to (void) from_type f = ACE_Numeric_Limits<from_type>::max (); // Should not be truncated. - if (Truncate<to_type> (f) != static_cast<to_type> (f)) + if (truncate_cast<to_type> (f) != static_cast<to_type> (f)) { success = false; @@ -140,8 +140,8 @@ sizeof_from_eq_sizeof_to (void) from_type f2 = ACE_Numeric_Limits<from_type>::max (); // Should not be truncated. - if (static_cast<from_type> (Truncate<to_type> (f1)) != f1 - || static_cast<from_type> (Truncate<to_type> (f2)) != f2) + if (static_cast<from_type> (truncate_cast<to_type> (f1)) != f1 + || static_cast<from_type> (truncate_cast<to_type> (f2)) != f2) { success = false; @@ -161,7 +161,7 @@ sizeof_from_eq_sizeof_to (void) from_type f = ACE_Numeric_Limits<from_type>::max (); // Should be truncated. - if (Truncate<to_type> (f) != ACE_Numeric_Limits<to_type>::max ()) + if (truncate_cast<to_type> (f) != ACE_Numeric_Limits<to_type>::max ()) { success = false; @@ -182,8 +182,8 @@ sizeof_from_eq_sizeof_to (void) from_type f2 = ACE_Numeric_Limits<from_type>::max (); // Should not be truncated. - if (Truncate<to_type> (f1) != f1 - || Truncate<to_type> (f2) != f2) + if (truncate_cast<to_type> (f1) != f1 + || truncate_cast<to_type> (f2) != f2) { success = false; @@ -203,7 +203,7 @@ sizeof_from_eq_sizeof_to (void) from_type f = ACE_Numeric_Limits<from_type>::max (); // Should not be truncated. - if (Truncate<to_type> (f) != f) + if (truncate_cast<to_type> (f) != f) { success = false; @@ -240,7 +240,7 @@ sizeof_from_gt_sizeof_to (void) from_type f = ACE_Numeric_Limits<from_type>::max (); // Should be truncated. - if (Truncate<to_type> (f) != ACE_Numeric_Limits<to_type>::max ()) + if (truncate_cast<to_type> (f) != ACE_Numeric_Limits<to_type>::max ()) { success = false; @@ -260,7 +260,7 @@ sizeof_from_gt_sizeof_to (void) from_type f = ACE_Numeric_Limits<from_type>::max (); // Should be truncated. - if (Truncate<to_type> (f) != ACE_Numeric_Limits<to_type>::max ()) + if (truncate_cast<to_type> (f) != ACE_Numeric_Limits<to_type>::max ()) { success = false; @@ -281,8 +281,8 @@ sizeof_from_gt_sizeof_to (void) from_type f2 = ACE_Numeric_Limits<from_type>::max (); // Should be truncated. - if (Truncate<to_type> (f1) != f1 - || Truncate<to_type> (f2) != ACE_Numeric_Limits<to_type>::max ()) + if (truncate_cast<to_type> (f1) != f1 + || truncate_cast<to_type> (f2) != ACE_Numeric_Limits<to_type>::max ()) { success = false; @@ -302,7 +302,7 @@ sizeof_from_gt_sizeof_to (void) from_type f = ACE_Numeric_Limits<from_type>::max (); // Should be truncated. - if (Truncate<to_type> (f) != ACE_Numeric_Limits<to_type>::max ()) + if (truncate_cast<to_type> (f) != ACE_Numeric_Limits<to_type>::max ()) { success = false; |