2 //=============================================================================
4 * @file DLList_Test.cpp
6 * This test illustrates the use of <ACE_DLList>.
8 * @author James Hu <jxh@cs.wustl.edu> and Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
10 //=============================================================================
13 #include "test_config.h"
14 #include "ace/Containers.h"
15 #include "ace/SString.h"
16 #include "ace/Malloc_T.h"
18 using ACE_STRING
= ACE_TCHAR
*;
19 using STRLIST
= ACE_DLList
<ACE_STRING
>;
20 using STRLIST_ITERATOR
= ACE_DLList_Iterator
<ACE_STRING
>;
21 using STRLIST_REVERSE_ITERATOR
= ACE_DLList_Reverse_Iterator
<ACE_STRING
>;
23 static ACE_STRING string_table
[] =
25 // Note: all these casts are to appease SC 5.0 which is not pleased
26 // with using string literals (i.e. const char *'s) as char
27 // *'s. It's ugly, but necessary.
28 const_cast<ACE_TCHAR
*> (ACE_TEXT ("hello")),
29 const_cast<ACE_TCHAR
*> (ACE_TEXT ("guten Tag")),
30 const_cast<ACE_TCHAR
*> (ACE_TEXT ("goodbye")),
31 const_cast<ACE_TCHAR
*> (ACE_TEXT ("auf wiedersehen")),
32 const_cast<ACE_TCHAR
*> (ACE_TEXT ("funny")),
33 const_cast<ACE_TCHAR
*> (ACE_TEXT ("lustig")),
38 run_iterate (STRLIST
&list
)
43 for (STRLIST_ITERATOR
iter (list
);
44 (entry
= iter
.next ()) != 0;
47 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("iterating (%d): [%s]\n"),
49 (ACE_TCHAR
*) *entry
));
54 run_reverse_iterate (STRLIST
&list
)
59 for (STRLIST_REVERSE_ITERATOR
iter (list
);
60 iter
.next (entry
) != 0;
63 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("iterating (%d): [%s]\n"),
65 (ACE_TCHAR
*) *entry
));
76 for (i
= 0; string_table
[i
] != 0; i
++)
79 && list
.insert_tail ((ACE_STRING
*) &string_table
[i
]) == 0)
80 ACE_ERROR_RETURN ((LM_ERROR
,
81 ACE_TEXT ("%p failed for %s\n"),
85 else if (list
.insert_head ((ACE_STRING
*) &string_table
[i
]) == 0)
86 ACE_ERROR_RETURN ((LM_ERROR
,
87 ACE_TEXT ("%p failed for %s\n"),
92 run_reverse_iterate (list
);
96 run_reverse_iterate (list
);
102 run_reverse_iterate (list
);
108 run_reverse_iterate (list
);
114 run_main (int, ACE_TCHAR
*[])
116 ACE_START_TEST (ACE_TEXT ("DLList_Test"));