2 //=============================================================================
4 * @file Hash_Map_Bucket_Iterator_Test.cpp
6 * This is a simple test of the <Hash_Map_Bucket_Iterator>.
8 * @author Irfan Pyarali <irfan@cs.wustl.edu>
10 //=============================================================================
13 #include "test_config.h"
14 #include "ace/OS_NS_stdlib.h"
15 #include "ace/Hash_Map_Manager.h"
16 #include "ace/Synch_Traits.h"
17 #include "ace/Null_Mutex.h"
18 #include "ace/Get_Opt.h"
19 #include "ace/Functor.h"
21 static ACE_UINT32 iterations
= ACE_MAX_ITERATIONS
* 10;
22 static ACE_UINT32 table_size
= ACE_MAX_ITERATIONS
;
25 parse_args (int argc
, ACE_TCHAR
*argv
[])
27 ACE_Get_Opt
get_opt (argc
, argv
, ACE_TEXT ("t:i:"));
31 while ((cc
= get_opt ()) != -1)
35 table_size
= ACE_OS::atoi (get_opt
.opt_arg ());
38 iterations
= ACE_OS::atoi (get_opt
.opt_arg ());
44 ACE_TEXT ("usage: %s ")
45 ACE_TEXT ("[-i (iterations)] ")
46 ACE_TEXT ("[-t (table size)] "),
47 ACE_TEXT ("Hash_Map_Bucket_Iterator_Test")));
54 using HASH_MAP
= ACE_Hash_Map_Manager_Ex
<ACE_UINT32
, ACE_UINT32
, ACE_Hash
<ACE_UINT32
>, ACE_Equal_To
<ACE_UINT32
>, ACE_MT_SYNCH::NULL_MUTEX
>;
56 using HASH_MAP_BUCKET_ITERATOR
= ACE_Hash_Map_Bucket_Iterator
<ACE_UINT32
, ACE_UINT32
, ACE_Hash
<ACE_UINT32
>, ACE_Equal_To
<ACE_UINT32
>, ACE_MT_SYNCH::NULL_MUTEX
>;
59 run_main (int argc
, ACE_TCHAR
*argv
[])
62 int result
= parse_args (argc
, argv
);
66 // Start the test only if options are valid.
67 ACE_START_TEST (ACE_TEXT ("Hash_Map_Bucket_Iterator_Test"));
68 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::VERBOSE_LITE
);
71 HASH_MAP
map (table_size
);
73 for (i
= 0; i
< iterations
; ++i
)
75 int result
= map
.bind (i
, i
);
76 ACE_TEST_ASSERT (result
== 0);
79 for (i
= 0; i
< table_size
; ++i
)
81 HASH_MAP_BUCKET_ITERATOR
iterator (map
,
84 HASH_MAP_BUCKET_ITERATOR
end (map
,
92 ACE_DEBUG ((LM_DEBUG
, "%d ", (*iterator
).int_id_
));
93 ACE_UINT32 key
= (*iterator
).ext_id_
;
94 ACE_TEST_ASSERT (((key
- i
) % table_size
) == 0);
97 ACE_DEBUG ((LM_DEBUG
, "\n"));
100 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::VERBOSE_LITE
);