diff options
Diffstat (limited to 'ACE/tests/UUID_Test.cpp')
-rw-r--r-- | ACE/tests/UUID_Test.cpp | 96 |
1 files changed, 46 insertions, 50 deletions
diff --git a/ACE/tests/UUID_Test.cpp b/ACE/tests/UUID_Test.cpp index 7f8cf15bc74..2c753475ebf 100644 --- a/ACE/tests/UUID_Test.cpp +++ b/ACE/tests/UUID_Test.cpp @@ -23,19 +23,9 @@ class Tester { public: - int init (void); int test (void); }; - -int -Tester::init (void) -{ - ///Initialise the UUID Generator - ACE_Utils::UUID_GENERATOR::instance ()->init (); - return 0; -} - int Tester::test (void) { @@ -45,81 +35,94 @@ Tester::test (void) auto_ptr <ACE_Utils::UUID> uuid (ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID ()); ACE_CString uuid_str (uuid->to_string ()->c_str ()); ACE_DEBUG ((LM_DEBUG, - "Generated UUID\n %s\n", + ACE_TEXT ("Generated UUID\n %s\n"), uuid_str.c_str ())); // Construct UUID from string ACE_Utils::UUID new_uuid (uuid_str); + ACE_DEBUG ((LM_DEBUG, - "UUID Constructed from above Generated UUID\n %s\n", + ACE_TEXT ("UUID Constructed from above Generated UUID\n %s\n"), new_uuid.to_string ()->c_str ())); // Construct UUID from string by assigning it ACE_Utils::UUID new_uuid_assign; new_uuid_assign.from_string (new_uuid.to_string ()->c_str ()); ACE_DEBUG ((LM_DEBUG, - "UUID Constructed from above Generated UUID with assign\n %s\n", + ACE_TEXT ("UUID Constructed from above Generated UUID ") + ACE_TEXT ("with assign\n %s\n"), new_uuid_assign.to_string ()->c_str ())); if (new_uuid != new_uuid_assign) - { - ACE_ERROR ((LM_ERROR, "Error: UUIDs are not the same\n")); - retval = -1; - } + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Error: UUIDs are not the same\n")), + -1); + + // Check the hash value of the 2 UUIDs + + if (new_uuid.hash () != new_uuid_assign.hash ()) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Error: hash value of UUIDs are ") + ACE_TEXT ("not the same")), + -1); // Construct UUID using the copy constructor ACE_Utils::UUID new_uuid_copy (new_uuid); ACE_DEBUG ((LM_DEBUG, - "UUID Constructed from above Generated UUID with copy\n %s\n", + ACE_TEXT ("UUID constructed from above Generated UUID") + ACE_TEXT (" with copy\n %s\n"), new_uuid_copy.to_string ()->c_str ())); if (new_uuid != new_uuid_copy) - { - ACE_ERROR ((LM_ERROR, "Error: UUIDs are not the same with copy\n")); - retval = -1; - } + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Error: UUIDs are not the same ") + ACE_TEXT ("with copy\n")), + -1); ACE_Utils::UUID nil_uuid (*ACE_Utils::UUID::NIL_UUID.to_string ()); ACE_DEBUG ((LM_DEBUG, - "UUID Constructed from NIL_UUID with string copy\n %s\n", + ACE_TEXT ("UUID Constructed from NIL_UUID with ") + ACE_TEXT ("string copy\n %s\n"), nil_uuid.to_string ()->c_str ())); if (nil_uuid != ACE_Utils::UUID::NIL_UUID) - { - ACE_ERROR ((LM_ERROR, "Error: UUIDs are not the same with NIL_UUID string copy\n")); - retval = -1; - } + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Error: UUIDs are not the same with ") + ACE_TEXT ("NIL_UUID string copy\n")), + -1); - // Construct UUID using the assignment constructor + // Construct UUID using the assignment constructor ACE_Utils::UUID new_uuid_assigment; new_uuid_assigment = new_uuid; ACE_DEBUG ((LM_DEBUG, - "UUID Constructed from above Generated UUID with assignment\n %s\n", + ACE_TEXT ("UUID Constructed from above Generated UUID ") + ACE_TEXT ("with assignment\n %s\n"), new_uuid_assigment.to_string ()->c_str ())); if (new_uuid != new_uuid_assigment) - { - ACE_ERROR ((LM_ERROR, "Error: UUIDs are not the same with assignment\n")); - retval = -1; - } + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Error: UUIDs are not the same " + ACE_TEXT ("with assignment\n"))), + -1); // Generate UUID with process and thread ids. - auto_ptr <ACE_Utils::UUID> uuid_with_tp_id (ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (0x0001, - 0xc0)); + auto_ptr <ACE_Utils::UUID> + uuid_with_tp_id (ACE_Utils::UUID_GENERATOR::instance ()->generate_UUID (0x0001, 0xc0)); + ACE_DEBUG ((LM_DEBUG, - "UUID with Thread and Process ID\n %s\n", + ACE_TEXT ("UUID with Thread and Process ID\n %s\n"), uuid_with_tp_id->to_string ()->c_str ())); if (new_uuid == *uuid_with_tp_id) - { - ACE_ERROR ((LM_ERROR, "Error: UUIDs are the same\n")); - retval = -1; - } + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Error: UUIDs are the same\n")), + -1); // Construct UUID from string ACE_Utils::UUID new_uuid_with_tp_id (uuid_with_tp_id->to_string ()->c_str ()); ACE_DEBUG ((LM_DEBUG, - "UUID with Thread and Process ID reconstructed from above UUID \n %s\n", + ACE_TEXT ("UUID with Thread and Process ID reconstructed ") + ACE_TEXT ("from above UUID \n %s\n"), new_uuid_with_tp_id.to_string ()->c_str ())); return retval; @@ -131,21 +134,14 @@ int run_main(int, ACE_TCHAR* []) Tester tester; - if (tester.init () == -1) - { - ACE_DEBUG((LM_DEBUG, - "UUIDTest: Tester::init failed\n")); - return -1; - } - int result = tester.test(); if (result == 0) ACE_DEBUG((LM_DEBUG, - "UUID_Test succeeded\n")); + ACE_TEXT ("UUID_Test succeeded\n"))); else ACE_ERROR((LM_ERROR, - "UUID_Test failed\n")); + ACE_TEXT ("UUID_Test failed\n"))); ACE_END_TEST; |