diff options
author | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-14 00:45:11 +0000 |
---|---|---|
committer | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-14 00:45:11 +0000 |
commit | bc774b0e11af6e81433cc6465bfbf0c7c79b448e (patch) | |
tree | c82c2eba1e561526eb32ef6e3bd516290455a55c /tests/Hash_Map_Manager_Test.cpp | |
parent | 17344ae1aa0bf37b3d89d3ace63cec856044df5f (diff) | |
download | ATCD-bc774b0e11af6e81433cc6465bfbf0c7c79b448e.tar.gz |
ACE coding style compliance changes. Suggestions from Doug.
Diffstat (limited to 'tests/Hash_Map_Manager_Test.cpp')
-rw-r--r-- | tests/Hash_Map_Manager_Test.cpp | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/tests/Hash_Map_Manager_Test.cpp b/tests/Hash_Map_Manager_Test.cpp index d08062b586e..eb374fa5e10 100644 --- a/tests/Hash_Map_Manager_Test.cpp +++ b/tests/Hash_Map_Manager_Test.cpp @@ -21,21 +21,27 @@ #include <iostream.h> #include "ace/Hash_Map_Manager.h" +#include "test_config.h" + +#define HASH_STRING_ENTRY ACE_Hash_Map_Entry<char *, char *> +#define HASH_STRING_MAP ACE_Hash_Map_Manager<char *, char *, ACE_Null_Mutex> #if defined (ACE_HAS_TEMPLATE_SPECIALIZATION) -ACE_Hash_Map_Entry<char * , char *>::ACE_Hash_Map_Entry (char * const &ext_id, - char * const &int_id, - ACE_Hash_Map_Entry<char *, char *> *ptr) - : ext_id_ (ext_id), +HASH_STRING_ENTRY::ACE_Hash_Map_Entry (char *const &ext_id, + char *const &int_id, + HASH_STRING_ENTRY *ptr) + : ext_id_ (ACE_OS::strdup (ext_id)), int_id_ (ACE_OS::strdup (int_id)), next_ (ptr) { + ACE_DEBUG ((LM_DEBUG, "Creating `%s' and `%s'\n", ext_id_, int_id_)); } -ACE_Hash_Map_Entry<char *, char *>::~ACE_Hash_Map_Entry (void) +HASH_STRING_ENTRY::~ACE_Hash_Map_Entry (void) { - cerr << "Freeing " << int_id_ << endl; + ACE_DEBUG ((LM_DEBUG, "Freeing `%s' and `%s'\n", ext_id_, int_id_)); + ACE_OS::free (ext_id_); ACE_OS::free (int_id_); } @@ -43,16 +49,15 @@ ACE_Hash_Map_Entry<char *, char *>::~ACE_Hash_Map_Entry (void) // char*, which doesn't have a hash() method defined on it. long unsigned int -ACE_Hash_Map_Manager<char *, char *, ACE_Null_Mutex>::hash (char * const & ext_id) +HASH_STRING_MAP::hash (char *const &ext_id) { return ACE::hash_pjw (ext_id); } int -ACE_Hash_Map_Manager<char *, char *, ACE_Null_Mutex>::equal (char * const & id1, - char * const & id2) +HASH_STRING_MAP::equal (char *const &id1, char *const &id2) { - return (ACE_OS::strcmp (id1, id2) == 0); + return ACE_OS::strcmp (id1, id2) == 0; } #endif /* ACE_HAS_TEMPLATE_SPECIALIZATION */ @@ -62,34 +67,40 @@ ACE_Hash_Map_Manager<char *, char *, ACE_Null_Mutex>::equal (char * const & id1, static const int MAX_HASH = 256; -int main(void) +int +main(void) { - ACE_Hash_Map_Manager<char *, char *, ACE_Null_Mutex> hash; - hash.open (MAX_HASH); + ACE_START_TEST ("Hash_Map_Manager_Test"); + + // Scoping below so that result of destruction can be seen in the log. + { + HASH_STRING_MAP hash (MAX_HASH); + + hash.bind ("hello", "guten Tag"); + hash.bind ("goodbye", "auf wiedersehen"); + hash.bind ("funny", "lustig"); - hash.bind ("hello", "guten Tag"); - hash.bind ("goodbye", "auf widersehen"); - hash.bind ("funny", "spiele"); + char * entry; - char * entry; + if (hash.find ("hello", entry) == 0) + ACE_DEBUG ((LM_DEBUG, "`%s' found `%s'\n", "hello", entry)); + if (hash.find ("goodbye", entry) == 0) + ACE_DEBUG ((LM_DEBUG, "`%s' found `%s'\n", "goodbye", entry)); + if (hash.find ("funny", entry) == 0) + ACE_DEBUG ((LM_DEBUG, "`%s' found `%s'\n", "funny", entry)); - if (hash.find ("hello", entry) == 0) - cout << "Found " << entry << endl; - if (hash.find ("goodbye", entry) == 0) - cout << "Found " << entry << endl; - if (hash.find ("funny", entry) == 0) - cout << "Found " << entry << endl; + hash.unbind ("goodbye", entry); - hash.unbind ("goodbye", entry); + if (hash.find ("hello", entry) == 0) + ACE_DEBUG ((LM_DEBUG, "`%s' found `%s'\n", "hello", entry)); + if (hash.find ("goodbye", entry) == 0) + ACE_DEBUG ((LM_DEBUG, "OOPS! `%s' found `%s'\n", "goodbye", entry)); + if (hash.find ("funny", entry) == 0) + ACE_DEBUG ((LM_DEBUG, "`%s' found `%s'\n", "funny", entry)); + } - if (hash.find ("hello", entry) == 0) - cout << "Found " << entry << endl; - if (hash.find ("goodbye", entry) == 0) - cout << "OOPS! Found " << entry << endl; - if (hash.find ("funny", entry) == 0) - cout << "Found " << entry << endl; + ACE_END_TEST; - hash.close (); return 0; } |