1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// $Id$
// ============================================================================
//
// = LIBRARY
// tests
//
// = FILENAME
// Collection_Test.cpp
//
// = DESCRIPTION
// This is a simple test of the ACE collection classes and its
// iterators.
//
// = AUTHOR
// Irfan Pyarali
//
// ============================================================================
#include "test_config.h"
ACE_RCSID(tests, Collection_Test, "$Id$")
#if defined(__BORLANDC__) && __BORLANDC__ >= 0x0530
USELIB("..\ace\aced.lib");
//---------------------------------------------------------------------------
#endif /* defined(__BORLANDC__) && __BORLANDC__ >= 0x0530 */
#include "ace/Containers.h"
typedef int DATA;
int main (int, ASYS_TCHAR *[])
{
ACE_START_TEST (ASYS_TEXT ("Collection_Test"));
typedef ACE_Unbounded_Set<DATA> UNBOUNDED_SET;
typedef ACE_Unbounded_Set_Iterator<DATA> UNBOUNDED_SET_ITERATOR;
{
UNBOUNDED_SET unbounded_set;
unbounded_set.insert (1);
unbounded_set.insert (2);
{
for (UNBOUNDED_SET::iterator iterator = unbounded_set.begin ();
iterator != unbounded_set.end ();
++iterator)
{
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("%d\n"),
(*iterator)));
}
}
{
UNBOUNDED_SET_ITERATOR iterator (unbounded_set);
while (!iterator.done ())
{
DATA *data = 0;
iterator.next (data);
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("%d\n"),
(*data)));
iterator.advance ();
}
}
}
typedef ACE_Array<DATA> ARRAY;
typedef ACE_Array_Iterator<DATA> ARRAY_ITERATOR;
{
ARRAY array;
}
{
ARRAY array (0);
}
{
ARRAY array1;
array1.size (2);
array1[0] = 4;
array1[1] = 4;
ARRAY array2 (2, 4);
ARRAY array3 (array2);
ARRAY array4;
array4 = array2;
ACE_ASSERT (array1 == array2);
ACE_ASSERT (array1 == array3);
ACE_ASSERT (array1 == array4);
{
for (size_t i = 0;
i != array1.size ();
++i)
{
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("%d\n"),
array1[i]));
ACE_ASSERT (array1[i] == 4);
}
}
{
ARRAY_ITERATOR iterator (array1);
while (!iterator.done ())
{
DATA *data = 0;
iterator.next (data);
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("%d\n"),
(*data)));
ACE_ASSERT (*data == 4);
iterator.advance ();
}
}
}
ACE_END_TEST;
return 0;
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Unbounded_Set<DATA>;
template class ACE_Unbounded_Set_Iterator<DATA>;
template class ACE_Node<DATA>;
template class ACE_Array<DATA>;
template class ACE_Array_Base<DATA>;
template class ACE_Array_Iterator<DATA>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Unbounded_Set<DATA>
#pragma instantiate ACE_Unbounded_Set_Iterator<DATA>
#pragma instantiate ACE_Node<DATA>
#pragma instantiate ACE_Array<DATA>
#pragma instantiate ACE_Array_Base<DATA>
#pragma instantiate ACE_Array_Iterator<DATA>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
|